The 12-Week DSA Mastery Roadmap
The goal here is to focus on one major topic per week, solve problems related to it, and then mix it
all up.
Phase 1: Solidifying the Foundations (Weeks 1-4)
Week 1: Arrays, Strings & Pointers
Concept: Master manipulating arrays and strings. Focus on two-pointer techniques, sliding
windows, and prefix sums. Revisit how pointers and memory work in C++.
Practice:
o CodeChef: 5-7 problems daily related to arrays and strings.
o LeetCode: 2-3 Easy/Medium problems. (e.g., "Two Sum", "Container With Most
Water").
o Goal: Get comfortable with C++ STL like vector and string.
Week 2: Recursion & Backtracking
Concept: This is a fundamental skill. Understand how to break down problems into smaller,
repeatable sub-problems.
Practice:
o CodeChef: Focus on recursion-based problems.
o LeetCode: 2-3 Medium problems. (e.g., "Subsets", "Permutations", "N-Queens").
o Goal: Be able to trace the recursion tree on paper.
Week 3: Linked Lists, Stacks & Queues
Concept: Learn the ins and outs of these linear data structures. Cover singly, doubly, and
circular linked lists.
Practice:
o CodeChef: Problems involving list traversals, stacks (LIFO), and queues (FIFO).
o LeetCode: 2-3 Easy/Medium problems. (e.g., "Reverse a Linked List", "Valid
Parentheses").
o Goal: Implement these data structures from scratch at least once.
Week 4: Sorting & Searching Algorithms
Concept: Deeply understand algorithms like Binary Search, Merge Sort, and Quick Sort. Know
their time and space complexities.
Practice:
o CodeChef/LeetCode: Find problems that can be optimized with Binary Search or
require custom sorting. (e.g., "Search in Rotated Sorted Array").
o Goal: Know when and why to use a specific sorting or searching algorithm.
Phase 2: Core Data Structures (Weeks 5-8)
Week 5: Trees (Binary Trees & BSTs)
Concept: Focus on tree traversals (In-order, Pre-order, Post-order, Level-order), and Binary
Search Tree (BST) properties.
Practice:
o LeetCode: This is the best platform for tree problems. Aim for 10-15 problems this
week. (e.g., "Maximum Depth of Binary Tree", "Validate Binary Search Tree").
o Goal: Be fluent in recursive tree traversal.
Week 6: Heaps & Hashing
Concept: Understand priority queues (heaps) for problems involving min/max elements.
Master hashing (using std::map, std::unordered_map, std::set in C++) for efficient lookups.
Practice:
o LeetCode: 2-3 problems daily. (e.g., "Top K Frequent Elements", "Find Median from
Data Stream").
o Goal: Recognize problems that can be simplified with a hash map or optimized with
a heap.
Week 7: Graphs
Concept: Learn graph representations (Adjacency List/Matrix) and basic traversals: Breadth-
First Search (BFS) and Depth-First Search (DFS).
Practice:
o LeetCode: 2-3 Medium graph problems. (e.g., "Number of Islands", "Clone Graph").
o Goal: Confidently implement both BFS and DFS.
Week 8: Advanced Graph Algorithms
Concept: Study Dijkstra's Algorithm (shortest path), and algorithms for Minimum Spanning
Trees (MST) like Prim's or Kruskal's.
Practice:
o CodeChef/LeetCode: Find specific problems on these algorithms. (e.g., "Network
Delay Time").
o Goal: Understand the use cases for each algorithm.
Phase 3: Advanced Topics & Contest Preparation (Weeks 9-12)
Week 9: Dynamic Programming (DP)
Concept: This is often the toughest topic. Start with the basics: memoization vs. tabulation.
Understand how to identify DP problems.
Practice:
o LeetCode: Spend the whole week here. Start with easy problems and build up. (e.g.,
"Climbing Stairs", "Coin Change", "Longest Increasing Subsequence").
o Goal: Solve at least 15-20 DP problems.
Week 10: Tries & Segment Trees
Concept: Learn about these specialized data structures. Tries for string-related problems (like
autocomplete) and Segment Trees for range query problems.
Practice:
o LeetCode/Codeforces: Find problems specifically tagged with "Trie" or "Segment
Tree".
o Goal: Understand the specific scenarios where these are useful.
Week 11 & 12: Mixed Practice & Contests
Concept: Now, mix everything together. The key is to quickly identify the right data structure
or algorithm for a random problem.
Practice:
o Solve problems from mixed topic lists.
o Participate in weekly contests on LeetCode, CodeChef, or Codeforces. This simulates
the real interview/competition environment and improves your speed.
o Upsolve: After a contest, spend time solving the problems you couldn't solve.
Extra Tips for Success
The 30-Minute Rule: If you're stuck on a problem for over 30 minutes, it's okay to look at a
hint or the solution. But don't just copy it. Understand the logic, close the solution, and code
it yourself. Revisit that same problem a few days later.
Quality over Quantity: 10 questions a day is great, but make sure you truly understand each
one. It's better to solve 5 problems and understand them deeply than to solve 10
superficially.
Track Your Progress: Keep a log (a simple spreadsheet works) of the problems you solve, the
topic, and how difficult you found it. This will help you identify and work on your weak spots.