DSA Roadmap
Data Structures and Algorithms (DSA) is one of the most learnable skills in software engineering — but only if you learn topics in the right order. Jump straight to dynamic programming before understanding arrays and you will struggle. Master the foundations and advanced topics become intuitive.
This roadmap organizes topics into three phases — Beginner, Intermediate, and Advanced — and gives you an honest timeline based on consistent daily practice (1–2 hours per day).
Phase 1: Foundations (4–6 weeks)
These topics appear in virtually every coding interview and form the building blocks for everything else. Do not rush past this phase — weak foundations cause confusion later.
Complexity Analysis — Big-O notation, time vs space, analyzing loops and recursion
Arrays — indexing, iteration, two-pointer technique, sliding window
Strings — character manipulation, substring problems, string hashing
Hash Maps & Hash Sets — O(1) lookup, frequency counting, grouping problems
Stacks — LIFO, monotonic stack, balanced parentheses, next greater element
Queues & Deques — FIFO, BFS traversal, sliding window maximum
Linked Lists — singly/doubly linked, fast-slow pointers, reversal
Recursion — base cases, recursive thinking, backtracking introduction
Phase 2: Core Data Structures & Algorithms (6–8 weeks)
With Phase 1 solid, these topics unlock the majority of Medium-level interview problems. Most FAANG phone screens test material from this phase.
Binary Search — sorted arrays, search on answer, rotated arrays, variants (lower/upper bound)
Sorting — merge sort, quicksort, heap sort, counting/radix sort, when to use each
Trees (Binary Trees) — DFS, BFS, traversals (preorder/inorder/postorder), level-order
Binary Search Trees — insert/delete/search, BST invariant, in-order gives sorted output
Heaps & Priority Queues — min-heap, max-heap, top-K problems, heap sort
Graphs — adjacency list/matrix, DFS, BFS, connected components, cycle detection
Two Pointers & Sliding Window — O(n) instead of O(n²) for subarray problems
Prefix Sums — O(1) range queries after O(n) preprocessing
Phase 3: Advanced Topics (8–12 weeks)
These topics separate good candidates from great ones. They appear in FAANG onsite rounds and competitive programming contests. Each topic requires Phase 1 and 2 as prerequisites.
Dynamic Programming — memoization, tabulation, common patterns (knapsack, LCS, LIS)
Backtracking — generate all solutions, pruning, combinations/permutations/subsets
Greedy Algorithms — interval scheduling, activity selection, Huffman coding
Tries — prefix trees, autocomplete, word search
Union-Find (Disjoint Set) — cycle detection, connected components, Kruskal MST
Segment Trees & Fenwick Trees — range queries with updates
Shortest Path Algorithms — Dijkstra, Bellman-Ford, Floyd-Warshall
Minimum Spanning Tree — Kruskal, Prim
Topological Sort — DAG ordering, course schedule, build systems
Advanced DP — bitmask DP, DP on trees, digit DP
Topic Dependency Map
Topic | Prerequisites | Unlocks |
|---|---|---|
Arrays | None | Two pointers, sliding window, most other topics |
Hash Maps | Arrays | Fast grouping, frequency problems, graph adjacency lists |
Stacks | Arrays | Monotonic stack, expression parsing, DFS iterative |
Binary Search | Arrays (sorted) | Search on answer, rotated array, binary search variants |
Recursion | Arrays, functions | Trees, graphs, backtracking, divide and conquer |
Linked Lists | Pointers/references | LRU cache, graph adjacency lists |
Trees | Recursion, queues | BST, heaps, tries, segment trees, DP on trees |
Graphs | Trees, hash maps | Shortest path, topological sort, MST, SCC |
Dynamic Programming | Recursion, arrays | Optimization problems, advanced graph DP |
Heaps | Trees | Priority queues, Dijkstra, top-K problems, heap sort |
Realistic Timeline
Phase | Duration | LeetCode Target | Goal |
|---|---|---|---|
Phase 1: Foundations | 4–6 weeks | ~50 Easy | Solve any Easy in < 20 min |
Phase 2: Core DSA | 6–8 weeks | ~80 Medium | Solve most Mediums in 30 min |
Phase 3: Advanced | 8–12 weeks | ~50 Medium + 20 Hard | Recognize patterns instantly |
Interview prep | 4 weeks | Review + mock interviews | Communicate solutions clearly |
What FAANG/Top Tech Companies Expect
Companies like Google, Meta, Amazon, Apple, Netflix, and Microsoft evaluate candidates on:
Correctness — does your solution handle all edge cases (empty input, single element, duplicates)?
Efficiency — can you state and achieve optimal time and space complexity?
Communication — do you think out loud, explain your approach before coding?
Clean code — readable variable names, proper structure, no spaghetti logic
Verification — do you trace through examples and test your own code?
The most common interview patterns by frequency at top companies:
Pattern | Frequency | Example Problems |
|---|---|---|
Arrays / Two Pointers | Very High | Two Sum, Container With Most Water, 3Sum |
Sliding Window | Very High | Longest Substring Without Repeating, Max Sliding Window |
Binary Search | High | Search Rotated Array, Find Peak Element, Koko Eating Bananas |
Tree DFS/BFS | High | Max Depth, Level Order, Path Sum, LCA |
Dynamic Programming | High | Climbing Stairs, Coin Change, Longest Common Subsequence |
Graph BFS/DFS | High | Number of Islands, Clone Graph, Course Schedule |
Hash Map | High | Group Anagrams, Top K Frequent, Subarray Sum Equals K |
Stack | Medium | Valid Parentheses, Daily Temperatures, Largest Rectangle in Histogram |
Heap / Priority Queue | Medium | Merge K Sorted Lists, K Closest Points, Task Scheduler |
Backtracking | Medium | Subsets, Permutations, N-Queens, Word Search |
Study Strategy
Learn the concept — understand why and how, not just what the code looks like
Implement from scratch — write the data structure or algorithm without looking it up
Solve 5–10 problems on that topic — start Easy, progress to Medium
Review wrong answers — understand WHY your solution failed before reading solutions
Spaced repetition — revisit topics after 1 week, then 1 month, then before interviews
Problem-Solving Framework
// The 6-step approach for any coding problem: // 1. UNDERSTAND: Restate the problem. Ask about constraints. // - Input/output types? Edge cases (empty, null, duplicates)? // - What are the size constraints on n? // 2. EXAMPLES: Work through 2-3 examples by hand (including edge cases). // - Build intuition before touching code. // 3. BRUTE FORCE: Describe the naive O(n²) or O(2^n) solution. // - Shows you understand the problem even if you cannot optimize yet. // 4. OPTIMIZE: Identify the bottleneck. Apply known patterns. // - Can I sort first? Use a hash map for O(1) lookup? // - Two pointers instead of nested loops? // - Binary search instead of linear scan? // 5. CODE: Write clean, readable code. // - Good variable names. Short functions. Avoid clever tricks. // 6. VERIFY: Trace through examples. Test edge cases. // - Empty input. Single element. All duplicates. Already sorted.