Introduction: The 20-Week DSA Roadmap
Welcome to the 20-Week Data Structures and Algorithms (DSA) Roadmap.
Whether you are preparing for grueling technical interviews at top-tier tech companies or aiming to become a significantly stronger backend engineer, mastering DSA is non-negotiable. This curriculum is not just a list of LeetCode problems; it is a carefully sequenced journey designed to build pattern recognition, algorithmic intuition, and system-level understanding using Java.
πΊοΈ The 5-Phase Journeyβ
This roadmap is broken down into five distinct phases, allowing you to gradually shift from how data is stored to how data is processed efficiently.
Phase 1: Core Data Structures & Linear Patterns (Weeks 1 - 4)β
- Focus: Arrays, Strings, Pointers, and Hash Maps.
- Goal: Master contiguous memory structures and O(N) linear traversals. You will learn to eliminate nested loops using Prefix Sums, Two Pointers, and Sliding Windows.
Phase 2: Trees, Graphs & Stack Patterns (Weeks 5 - 8)β
- Focus: Stacks, Queues, Binary Trees, BSTs, and Graph traversals (DFS/BFS).
- Goal: Transition from linear to hierarchical data. You will master recursion, the Call Stack, and the highly-tested Monotonic Stack pattern.
Phase 3: Core Algorithms & Scheduling (Weeks 9 - 12)β
- Focus: Binary Search, Backtracking, Intervals, and Heaps (Priority Queues).
- Goal: Learn how to search "Answer Spaces" in O(log N) time, navigate complex decision trees, and handle overlapping chronological events (Sweep Line).
Phase 4: Intermediate Techniques & Optimization (Weeks 13 - 16)β
- Focus: 1D and 2D Dynamic Programming, Variable Sliding Windows, and Tries.
- Goal: Conquer the most intimidating interview topics. You will learn how to cache overlapping subproblems and build hyper-fast prefix trees for string searching.
Phase 5: Advanced Techniques + Review (Weeks 17 - 20)β
- Focus: Shortest Paths (Dijkstra), Minimum Spanning Trees (Prim/Kruskal), Union-Find (DSU), and Bit Manipulation.
- Goal: Finalize niche graph algorithms and synthesize your knowledge by mapping abstract data structures to real-world distributed systems.
π§± Prerequisite Matrix (Weeks 1-20)β
Use this as a quick readiness check before each week. If you are missing one or two items, spend a short review block first, then continue.
| Week | Topic | Knowledge Needed Before Starting |
|---|---|---|
| 1 | Arrays, Strings & Prefix Sums | Java basics, Big-O fundamentals, 0-indexing, java.util basics |
| 2 | Two Pointers & Basic Sliding Window | Week 1 mastery, sorting intuition, boundary/index math, loop invariants |
| 3 | Linked Lists & Fast/Slow Pointers | Week 1-2 traversal confidence, Java references, null-safety, pointer tracing |
| 4 | Hash Tables & Sets | Week 1-3 fluency, identity vs equality, average vs worst-case Big-O, key-value modeling |
| 5 | Stacks, Queues & Monotonic Stack | Array traversal fluency, ArrayDeque basics, amortized analysis, pattern recognition |
| 6 | Binary Trees & BSTs | Stack/queue intuition, recursion basics, TreeNode modeling, null branching discipline |
| 7 | Graph Foundations | DFS/BFS on trees, queue/stack usage, matrix boundary checks, node-edge modeling |
| 8 | Advanced Graph Concepts | Week 7 graph fluency, visited-state discipline, dependency direction modeling, in-degree arrays |
| 9 | Binary Search & Answer Space | Sorted-data reasoning, boundary invariants, monotonic predicates, overflow-safe midpoint |
| 10 | Recursion & Backtracking | Call-stack intuition, base-case design, recursion tracing, choose-explore-unchoose mutation control |
| 11 | Intervals & Sweep Line | Comparator-safe sorting, pair/event modeling, prefix-style accumulation thinking, interval boundary semantics |
| 12 | Heaps & Greedy | Heap/tree shape intuition, PriorityQueue comparators, greedy-choice reasoning, local-vs-global trade-offs |
| 13 | Dynamic Programming I (1D) | Recursion fluency, transition thinking, memo/table state modeling, small-example tracing habit |
| 14 | Dynamic Programming II (2D) | Week 13 recurrence mastery, matrix indexing, 2-variable state translation, table fill-order reasoning |
| 15 | Advanced Sliding Windows | Fixed-window foundation, frequency-map fluency, moving-window invariants, amortized 2-pointer proof |
| 16 | Tries (Prefix Trees) | String indexing, tree traversal, HashMap-vs-array node design trade-offs, DFS confidence |
| 17 | Shortest Paths & MST | Graph representation/traversal, heap proficiency, greedy proof intuition, path-vs-network cost distinction |
| 18 | Disjoint Set Union | Connectivity modeling, parent/rank arrays, amortized complexity intuition, dynamic vs static query awareness |
| 19 | Bit Manipulation & Math | Binary representation basics, signed/unsigned intuition, modular arithmetic basics, bitmask state mapping |
| 20 | Comprehensive Review & System Mappings | Weeks 1-19 completion, trade-off communication, brute-force-to-optimal storytelling, Java API fluency under pressure |
π§ Rules for Successβ
To get the most out of this curriculum, you must approach it with the right mindset and discipline.
1. The 45-Minute Ruleβ
Do not spend more than 45 minutes staring at a blank screen. If you cannot find the optimal solution within this time frame, look at the solution. However, never copy-paste. Read the solution, understand the pattern, close the solution, and write the code from scratch.
2. Focus on Patterns, Not Memorizationβ
Memorizing a solution to Two Sum is useless. Understanding that a HashMap can trade O(N) space for O(1) time to find complements is invaluable. Every week includes a Pattern Recognition Guideβstudy it religiously.
3. Communicate Before You Codeβ
Every week includes a Mock Interview Module. Treat these seriously. Before writing a single line of Java in your IDE or on LeetCode:
- Clarify the constraints (e.g., "Can the array be empty?").
- State the Brute Force solution out loud.
- Propose the Optimized solution and explain its Time and Space Complexity (Big O).
4. Pace Yourselfβ
The curriculum recommends 3 problems a day (21 per week). If you work full-time, this might be aggressive. It is perfectly fine to stretch a "Week" into 10 or 14 days. Consistency beats intensity.
π οΈ Environment Setupβ
While concepts are language-agnostic, the templates provided in this guide are heavily optimized for Java.
- IDE: Set up IntelliJ IDEA or Eclipse. Practice debugging recursive trees using breakpoints.
- Standard Library: Familiarize yourself with the
java.utilpackage. You must know the methods forHashMap,HashSet,ArrayDeque(used for both Stacks and Queues),PriorityQueue, andStringBuilderby heart. - LeetCode/NeetCode: Create an account to track your progress on the recommended practice problems.
π Ready to Begin?β
Start your journey by navigating to Week 1: Arrays, Strings & Prefix Sums. Trust the process, stay consistent, and happy coding!
π§ Quick Navigationβ
- Week 1: Arrays, Strings & Prefix Sums
- Week 2: Two Pointers & Basic Sliding Window
- Week 3: Linked Lists & Fast/Slow Pointers
- Week 4: Hash Tables & Sets
- Week 5: Stacks, Queues & Monotonic Stack
- Week 6: Binary Trees & BSTs
- Week 7: Graph Foundations
- Week 8: Advanced Graph Concepts
- Week 9: Binary Search & The Answer Space
- Week 10: Recursion & Backtracking
- Week 11: Intervals & Sweep Line Algorithms
- Week 12: Heaps (Priority Queues) & Greedy Algorithms
- Week 13: Dynamic Programming I (1D)
- Week 14: Dynamic Programming II (2D)
- Week 15: Advanced Sliding Windows
- Week 16: Tries (Prefix Trees)
- Week 17: Shortest Paths & MST
- Week 18: Disjoint Set Union (Union-Find)
- Week 19: Bit Manipulation & Math
- Week 20: Comprehensive Review & System Design Mappings