Skip to main content

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.

WeekTopicKnowledge Needed Before Starting
1Arrays, Strings & Prefix SumsJava basics, Big-O fundamentals, 0-indexing, java.util basics
2Two Pointers & Basic Sliding WindowWeek 1 mastery, sorting intuition, boundary/index math, loop invariants
3Linked Lists & Fast/Slow PointersWeek 1-2 traversal confidence, Java references, null-safety, pointer tracing
4Hash Tables & SetsWeek 1-3 fluency, identity vs equality, average vs worst-case Big-O, key-value modeling
5Stacks, Queues & Monotonic StackArray traversal fluency, ArrayDeque basics, amortized analysis, pattern recognition
6Binary Trees & BSTsStack/queue intuition, recursion basics, TreeNode modeling, null branching discipline
7Graph FoundationsDFS/BFS on trees, queue/stack usage, matrix boundary checks, node-edge modeling
8Advanced Graph ConceptsWeek 7 graph fluency, visited-state discipline, dependency direction modeling, in-degree arrays
9Binary Search & Answer SpaceSorted-data reasoning, boundary invariants, monotonic predicates, overflow-safe midpoint
10Recursion & BacktrackingCall-stack intuition, base-case design, recursion tracing, choose-explore-unchoose mutation control
11Intervals & Sweep LineComparator-safe sorting, pair/event modeling, prefix-style accumulation thinking, interval boundary semantics
12Heaps & GreedyHeap/tree shape intuition, PriorityQueue comparators, greedy-choice reasoning, local-vs-global trade-offs
13Dynamic Programming I (1D)Recursion fluency, transition thinking, memo/table state modeling, small-example tracing habit
14Dynamic Programming II (2D)Week 13 recurrence mastery, matrix indexing, 2-variable state translation, table fill-order reasoning
15Advanced Sliding WindowsFixed-window foundation, frequency-map fluency, moving-window invariants, amortized 2-pointer proof
16Tries (Prefix Trees)String indexing, tree traversal, HashMap-vs-array node design trade-offs, DFS confidence
17Shortest Paths & MSTGraph representation/traversal, heap proficiency, greedy proof intuition, path-vs-network cost distinction
18Disjoint Set UnionConnectivity modeling, parent/rank arrays, amortized complexity intuition, dynamic vs static query awareness
19Bit Manipulation & MathBinary representation basics, signed/unsigned intuition, modular arithmetic basics, bitmask state mapping
20Comprehensive Review & System MappingsWeeks 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.

  1. IDE: Set up IntelliJ IDEA or Eclipse. Practice debugging recursive trees using breakpoints.
  2. Standard Library: Familiarize yourself with the java.util package. You must know the methods for HashMap, HashSet, ArrayDeque (used for both Stacks and Queues), PriorityQueue, and StringBuilder by heart.
  3. 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