Zero-to-Hero Roadmap β
- βW1 β Foundations
- βW2 β Arrays / Hashing / Prefix Sum
- βW3 β Two Pointers / Binary Search
- βW4 β Stacks / Monotonic / SW Max
- βW5 β Heaps / Top-K / K-way Merge
- βW6 β Trees / BSTs / Trie
- βW7 β Graphs / BFS-DFS / Topo / UF
- βW8 β DP / Backtracking / Design
- βW9-10 β Rehearsal
- βW11-12 β Final push
A concrete, day-by-day plan a working engineer can actually follow. The book will not teach you if you read it front-to-back like a novel β patterns stick only through spaced practice on canonical problems. This chapter tells you exactly what to do on Monday morning.
Pre-flight quiz β are you ready for patterns? β
Do NOT start Part II until you can answer these ten in under 30 seconds each without looking anything up. If you miss more than two, go finish Part I first.
- What is the time complexity of
list.contains(x)whenlistis anArrayList<Integer>of size n? (O(n) β it's a linear scan.) - What is the amortized cost of
HashMap.put? What's the worst case? (O(1) amortized; O(n) worst if every key collides.) - In
ArrayDeque, which end ispush/pop? Which end isoffer/poll? (push/pop= head, LIFO.offer/poll= tail-in, head-out, FIFO.) - What's
Integer.MIN_VALUE * -1in Java? (StillInteger.MIN_VALUEβ overflow wraps.) - Given
n = 10β΅, which complexities fit under 1 second? (O(n), O(n log n), O(n βn). O(nΒ²) is borderline; O(nΒ³) fails.) - What does
(lo + hi) / 2fail on, and what's the fix? (Overflow whenlo + hi > Integer.MAX_VALUE. Uselo + (hi - lo) / 2.) - In
TreeMap<Integer,V>, what doesfloorKey(x)return? (The greatest key β€ x, ornullif none exists.) - What's the difference between
String.equalsand==? (equalscompares content;==compares references. Interned strings can accidentally pass==.) - What's the space complexity of a recursive function that recurses
ntimes without tail-call optimization? (O(n) β Java doesn't do TCO; every frame stays on the stack.) - Why is
ArrayDequepreferred overStackin modern Java? (StackextendsVectorwhich is synchronized;ArrayDequeis faster and idiomatic.)
9-10: skip Part I, start Part II. 6-8: skim Part I, focus on gaps. β€ 5: read Part I fully before Part II.
The three tracks β pick one β
Your track depends on your calendar constraint, not your skill level. All three land at the same competence β they just spread it differently.
| Track | Weeks | Weekly commitment | For whom |
|---|---|---|---|
| Sprint | 4 | 15β20 hrs | Interview in a month; strong Java baseline |
| Standard | 8 | 8β10 hrs | Interview in ~two months; want depth without cramming |
| Marathon | 12 | 5β7 hrs | Long-horizon prep; also learning fundamentals |
Below I lay out the Standard 8-week plan as the default. Sprint compresses each pair of weeks into one; Marathon expands each week into 1.5.
The weekly cadence β do the same shape every week β
Every week (regardless of track), your five practice sessions look like this:
| Session | Duration | What you do |
|---|---|---|
| Study (Mon) | 60 min | Read one pattern chapter's story + templates + one canonical problem. No coding yet. |
| Canonical (Tue/Wed) | 45 min Γ 2 | Code the week's 2 canonical problems from scratch on a blank editor. Time yourself. |
| Variations (Thu) | 45 min | Solve 2 variations of the week's pattern β proves you learned the idea, not the specific solution. |
| Weakness (Fri) | 60 min | Pick any problem you failed earlier and re-solve it without looking. This is where retention actually happens. |
| Mock (Sat) | 60 min | Full mock β think aloud, clarify, brute force β optimize β code β verify. Grade yourself with the interview playbook. |
Sundays are for rest. Retention needs sleep, not extra grinding.
At least 30% of your weekly hours must go to problems you've already solved once. Fresh problems feel productive; re-solving is where mastery is built. If you skip re-solving, you'll forget every pattern within 3 weeks of the interview.
The 8-week Standard Plan β
Week 1 β Foundations you can't skip β
- Read:
06-java-ds.md(Java primer).07-java-gotchas.md.10-complexity.md. - Do: On paper, without an IDE, implement:
- A stack using an array (grow-when-full)
- A hash map with open addressing (linear probing)
- Binary search β the
[lo, hi)half-open version only
- Canonical: Two Sum, Valid Anagram β with both brute-force and optimized versions and complexity for each.
- Weekend mock: Two Sum, aloud, timed. Grade yourself: did you propose brute force first? Did you state complexity before coding?
Week 2 β Arrays, Hashing, Prefix Sum β
- Patterns: Chapters 21 (Sliding Window β read the whole thing), 25 (Hashing), 24 (Prefix Sum).
- Canonical: Longest Substring Without Repeating Characters, Subarray Sum Equals K.
- Variations: Longest Consecutive Sequence, Group Anagrams.
- Trap to internalize:
HashMap.get(k)returnsnullif absent β not0. UsegetOrDefaultormerge.
Week 3 β Two Pointers, Fast/Slow, Binary Search β
- Patterns: 22 (Two Pointers), 23 (Fast/Slow), 27 (Binary Search), 28 (BS on Answer).
- Canonical: 3Sum, Search in Rotated Sorted Array.
- Variations: Container With Most Water, Koko Eating Bananas, Linked List Cycle II.
- Focus: Binary Search's boundary conventions. Pick
[lo, hi)half-open and stick with it. All the off-by-ones vanish.
Week 4 β Stacks, Queues, Monotonic Stack, Sliding Window Max β
- Patterns: 26 (Monotonic Stack), and revisit 21 for Sliding Window Maximum (monotonic deque).
- Data structure: 58 (Stacks & Queues).
- Canonical: Daily Temperatures, Largest Rectangle in Histogram.
- Variations: Sliding Window Maximum, Trapping Rain Water (both mono-stack and two-pointer solutions).
- Interview mindset: A stack solving a problem often means "for each item, find the next greater/smaller." Recognize this signal instantly.
Week 5 β Heaps, Top-K, K-way Merge, Quickselect β
- Patterns: 29 (Top-K/Heap), 30 (K-way Merge), 41 (Quickselect).
- Data structure: 62 (Heaps).
- Canonical: Top K Frequent Elements, Merge k Sorted Lists.
- Variations: Find Median from Data Stream, Kth Largest Element in an Array (solve twice β once with heap, once with quickselect).
- Focus: When to reach for a heap vs. sort vs. quickselect β the "one-shot vs streaming" question.
Week 6 β Trees, BSTs, Trie β
- Patterns: 39 (Trie).
- Data structures: 60 (Trees), 64 (Trie).
- Canonical: Binary Tree Level Order Traversal, Validate Binary Search Tree, Implement Trie.
- Variations: Lowest Common Ancestor of a Binary Tree, Diameter of Binary Tree, Serialize and Deserialize Binary Tree.
- Interview mindset: For trees, ask two questions at each node: what do I need from my children? (post-order return) and what did my parent give me? (pre-order context). Everything else is variations on those.
Week 7 β Graphs, BFS/DFS, Topo Sort, Union-Find β
- Patterns: 33 (Topological Sort), 34 (Union-Find), 66 (Graphs).
- Canonical: Number of Islands, Course Schedule II, Number of Provinces.
- Variations: Rotting Oranges, Network Delay Time (Dijkstra), Min Cost to Connect All Points (MST).
- Focus: Choose your representation before you write a line. Adjacency list for sparse graphs, adjacency matrix only when V β€ 500 and dense.
Week 8 β DP, Backtracking, Design β
- Patterns: 36 (Backtracking), 38 (Dynamic Programming), 44 (Design).
- Canonical: House Robber, Coin Change, LRU Cache, Subsets.
- Variations: Longest Common Subsequence, Edit Distance, N-Queens, Word Search II (Trie + backtracking).
- Focus: DP state design. If you can't name what a
dp[i]cell means in one sentence, you can't code it. Spend as much time on the definition as on the transition.
Weeks 9β10 (Sprint = W3-4; Marathon = spread across weeks 9-14) β
Retention consolidation. No new patterns. Re-solve everything.
- Monday: Re-solve one problem from every pattern you learned (that's 21 problems in ~5 hrs β you'll be fast now).
- TuesdayβThursday: One mock interview per day, unseen problems from LeetCode top-100.
- Friday: Grade all three mocks against the interview playbook rubric. Fix your weakest phase.
Weeks 11β12 (final push, or first two weeks of Marathon closing) β
System design overlay + hard problems.
- System design: 1 hour daily. Not covered here β see Alex Xu / DDIA β but the DSA patterns you learned show up (LRU cache, consistent hashing, rate limiter).
- Hard problems: Median of Two Sorted Arrays, Serialize/Deserialize Binary Tree, Trapping Rain Water, Word Break II, Regular Expression Matching, Sliding Window Maximum, Longest Increasing Path in a Matrix.
- Interview eve: Only read Part II (patterns) and Part IV (cheat sheets). No new problems in the final 48 hours.
What "you're ready" looks like β
Sign one is easy: you recognize the pattern in under 30 seconds. But that's not sufficient. All three of these must be true:
- Recognition β You read a problem and, within 30 seconds, you can name the pattern and often the exact template you'll use.
- Communication β You can walk through your solution aloud without freezing, and you naturally propose brute-force before optimized. You know the complexity of every step before you write it.
- Recovery β When your first idea doesn't work, you don't panic. You state what changed, propose an alternative, and move on. This is the difference between senior and mid-level.
If any of the three is missing, keep drilling. The book has enough material for another full pass.
Grinding 500 LeetCode problems without a plan. Volume without spacing doesn't build recognition. 60 canonical problems drilled 3Γ each beats 500 problems solved once. That's the entire premise of this book.
Signs you're ready for staff-level (not just senior) β
Passing a senior interview requires the three above. Staff adds three more:
- Decomposition β You can turn a fuzzy real-world problem ("build me a rate limiter") into concrete data-structure choices with tradeoffs you can defend.
- Approximation β You know when the "optimal" answer isn't worth it. Bloom filter instead of hash set (memory), quickselect instead of sort (need only k-th), sampling instead of full scan.
- Systems eye β You spot when a DSA problem is really a systems problem. "Design a top-K feed" isn't
PriorityQueue; it's count-min sketch + heavy hitters + heap merge β and you'd never fit that on a whiteboard, so you narrate the tradeoff.
If you hit staff signal in the first 20 minutes of an interview, expect harder problems. The book helps here but real staff interviews test judgment as much as code.
Common mistakes on this roadmap β
- "I'll skip the pre-flight quiz." Do the quiz. If you can't answer autoboxing / overflow /
ArrayDeque, you'll waste hours debugging Java specifics that have nothing to do with the algorithm. The quiz takes 5 minutes. - "I'll do 10 problems this weekend and catch up." Retention is a function of spacing, not volume. Ten problems in a weekend are forgotten by Wednesday. Two problems per day for five days aren't.
- "I'll skip the mocks β I'll do them when I feel ready." You'll never feel ready. The whole point of the mock is to expose what you don't yet have. Do them from Week 1.
- "I'll just read the book." Reading builds recognition; only writing code builds recall. The plan asks for 2 canonical + 2 variations + 1 re-solve per week for a reason.
- "I'll skip re-solving problems I already got right." This is the single biggest mistake. See "30% rule" above. Retention decays exponentially without re-exposure.
What to do when you're stuck β
Every serious engineer gets stuck. Here's the escalation order β do NOT skip steps.
- Re-read the problem statement. Half of stuck-ness is misread constraints (n β€ 10β΅ vs 10β· changes everything).
- State an example. Pick the smallest input the problem allows. Trace what the answer should be by hand.
- State the brute force. Even if it's O(nΒ³) β say it out loud. This unlocks the "optimize what?" question.
- Look at what the input is shaped like. Sorted? β binary search / two pointers. Overlapping ranges? β merge intervals. Prefix / suffix? β prefix sum. Contiguous? β sliding window.
- Read only the pattern's Recognize-by callout in this book β not the code. If it clicks, close the book and code it.
- Look at the code template β but not the specific problem's solution.
- Look at the solution. Now: close everything, re-solve from a blank editor 24 hours later. If you can't, you didn't learn β you copied.
Discipline in step 7 is the single biggest predictor of interview success.