DSA Roadmap
A six-week, interview-focused DSA plan with curated LeetCode practice.
Purpose: prepare for a possible Amazon SDE Intern technical interview after the OA.
Last updated: 12 November 2026
Format: a flexible six-week sequence, not a deadline. Complete the Core questions first; use Stretch questions if you have time or already know the basics. Questions are linked to LeetCode unless noted.
The Core and Stretch lists include selections from the Amazon Thirty Days snapshot, alongside fundamentals and reported interview practice. The source repository says its data was updated on 20 October 2025; “Thirty Days” describes that historical snapshot, not the last 30 days today. Company tags and frequency scores are signals for practice, not a guarantee of interview questions.
Tick a question as complete to save your progress automatically in this browser. Progress stays on this device and is not synced across browsers; clearing this site's storage resets it.
Use one language for your timed coding practice. If a Core question introduces a pattern you cannot yet solve, do an easy warmup on that pattern, then return to the Core question. Move on to mixed medium questions as the fundamentals become comfortable.
Interview reports point to live DSA coding plus behavioral/project discussion. This roadmap focuses on DSA. The interview count and exact questions are not guaranteed. See the interview process research and pair this with short sessions from the Core CS roadmap.
How to practice each question
- Try it independently for 25–35 minutes before looking at hints or a solution.
- Say the approach out loud: clarify inputs, give a simple approach, then improve it.
- State time and space complexity before coding.
- Code, dry-run a normal example, and test at least two edge cases.
- If stuck, study the key idea, close the solution, and solve it again the next day.
- Keep a short error log: missed pattern, wrong invariant, edge case, implementation bug, or complexity issue. Revisit missed problems after 2–3 days and again after a week.
A problem is “done” when you can explain and re-implement the solution—not just recognize it after reading the answer.
Use AI as a reviewer after your attempt
First solve or make a serious timed attempt yourself. Then ask an AI tool to critique without revealing a complete solution yet. For example:
Here is the problem, my approach, complexity claim, code, and test cases. Check the reasoning for counterexamples and missed edge cases. Ask me one follow-up question and suggest a similar problem. Give hints first; do not show a full solution unless I ask.
Run any counterexample it suggests and check its claims against your code or a trusted editorial. If the approach is wrong, revise it yourself before reading a full answer. Use AI feedback during practice, subject to the rules of any real interview or assessment.
Six-week sequence
Week 1 — Arrays, strings, hash maps, prefix sums
Learn: frequency maps, sets, counting, prefix sums, running products, and trading extra memory for faster lookup.
Core
- Two Sum — #1
- Best Time to Buy and Sell Stock — #121
- Valid Sudoku — #36
- Group Anagrams — #49
- Product of Array Except Self — #238
- Subarray Sum Equals K — #560
- Longest Consecutive Sequence — #128
Stretch
Week 2 — Two pointers and sliding window
Learn: when a sorted array enables two pointers; fixed- versus variable-size windows; how to maintain a window invariant.
Core
- Longest Substring Without Repeating Characters — #3
- Max Consecutive Ones III — #1004
- Container With Most Water — #11
- 3Sum — #15
- Minimum Size Subarray Sum — #209
- Permutation in String — #567
Stretch
Week 3 — Binary search, intervals, stacks
Learn: binary-search boundaries and invariants; sorting intervals; stack use for matching and next-greater-element patterns.
Core
- Search in Rotated Sorted Array — #33
- Koko Eating Bananas — #875
- Single Element in a Sorted Array — #540 — reported in a recent intern interview
- Merge Intervals — #56
- Non-overlapping Intervals — #435
- Valid Parentheses — #20
- Daily Temperatures — #739
Stretch
Week 4 — Linked lists and binary trees
Learn: pointer manipulation, fast/slow pointers, recursive versus iterative DFS, BFS by level, BST ordering, and tree-to-graph thinking.
Core
- Reverse Linked List — #206
- Add Two Numbers — #2
- LRU Cache — #146
- Merge Two Sorted Lists — #21
- Remove Nth Node From End of List — #19
- Maximum Depth of Binary Tree — #104
- Binary Tree Level Order Traversal — #102
- Validate Binary Search Tree — #98
- Lowest Common Ancestor of a Binary Tree — #236
- All Nodes Distance K in Binary Tree — #863 — useful tree-to-graph/BFS practice; related to “burning tree” questions
Level-order follow-up: Solve Binary Tree Zigzag Level Order Traversal — #103 after #102. Run BFS one level at a time, placing values left-to-right on one level and right-to-left on the next. For the complete tree with values 1 through 7, the flattened output is 1, 3, 2, 4, 5, 6, 7. Explain why every node is processed once: O(n) time and O(n) worst-case space including the queue and output. Compare reversing alternate level arrays with writing into the correct indices directly.
Stretch
- Copy List with Random Pointer — #138
- Binary Tree Right Side View — #199
- Binary Tree Maximum Path Sum — #124
Week 5 — Heaps and greedy algorithms
Learn: min-heap versus max-heap, maintaining top K, choosing a greedy rule and proving why it works.
Core
- Kth Largest Element in an Array — #215
- Kth Largest Element in a Stream — #703
- Reorganize String — #767 — reported in an intern interview
- Jump Game — #55
- Gas Station — #134
Stretch
OA-style greedy variant: equalize an array by copying a value left or right
A shared OA recollection describes the same operations as Codeforces 2111C — Equal Values: choose index i (zero-based), copy a[i] to every position on its left for cost i × a[i], or to every position on its right for cost (n - 1 - i) × a[i]. Operations may be repeated. Assume a nonempty array of positive integers; copying over values that already match still costs the full amount.
Greedy observation: Keep one original contiguous run of value v and length L. Copy from its left end to cover everything before it and from its right end to cover everything after it. The cost is (n - L) × v. Scan all equal-value runs and take the minimum: O(n) time and O(1) extra space. This also gives 0 when the whole array is already equal. Be ready to explain why additional operations cannot improve on the best run, and use a wide integer type for the cost.
Check the recalled sample: For [5, 1, 1, 2, 1, 1], the run at indices 1..2 costs 1 + 3 = 4. The reported answer 3 does not follow from these operations; ask whether the original prompt had a different cost or operation rule. Treat this as extra greedy practice, not a prediction of your interview question.
Reorganize String: explain the constraints, not just the code
For Reorganize String — #767, let N be the string length and K the number of distinct characters. First count frequencies. A valid arrangement is impossible when max_frequency > ceil(N / 2); the comparison is constant time after the frequency count, which takes O(N) time.
| Approach | Time | Extra space, excluding the answer | Discussion point |
|---|---|---|---|
| Try arrangements with backtracking | Exponential, up to factorial | O(N + K) | Establishes a baseline; impractical for long strings |
| Max-heap with previous character held out for one step | O(N log(K + 1)) | O(K) | Works with a frequency map and extends naturally to cooldown variants |
| Put the most frequent character in even positions first, then fill remaining even and odd positions | O(N + K) | O(K) | Avoids heap work; for a fixed 26-letter alphabet, this is O(N) time and O(1) extra space |
The returned string itself takes O(N) space in either constructive approach. The even/odd method relies on placing the most frequent character first and wrapping from the even slots to index 1 inside the placement loop. Test impossible input ("aaab"), a tight valid case ("aab"), all unique characters, and an input such as "vvvlo" that exercises the wrap. Explain why the frequency bound and placement order prevent adjacent duplicates.
For Rearrange String k Distance Apart — #358, use a cooldown queue of the last k placements with the heap; a character becomes eligible again only after enough other positions have been filled. Check what to return if the heap empties while characters remain in cooldown. A fixed array<int, 26> and C++ char implementation handles lowercase English letters, not arbitrary Unicode; ask about the alphabet before choosing the representation.
Week 6 — Graphs, backtracking, and introductory dynamic programming
Learn: adjacency lists, visited sets, BFS/DFS, connected components, cycle detection/topological sort, recursion trees, and building a DP state from smaller subproblems.
Core
- Number of Islands — #200
- Rotting Oranges — #994
- Clone Graph — #133
- Course Schedule — #207
- Subsets — #78
- Combination Sum — #39
- Generate Parentheses — #22
- Maximum Subarray — #53
- Climbing Stairs — #70
- House Robber — #198
- Coin Change — #322
Connected-components follow-up: Reframe #200 as “minimum delivery partners”: each connected group of house cells ('1') needs one partner; empty cells are '0'. Clarify whether connection means four directions or includes diagonals before coding. Start a DFS or BFS at each unvisited house, count that component once, and mark its houses visited. This takes O(m × n) time and O(m × n) worst-case space for visited state and traversal storage. Test an empty grid, isolated houses, and one large component; use iterative traversal if recursion depth is a concern.
Stretch
- Redundant Connection — #684 — union-find
- Network Delay Time — #743 — Dijkstra’s algorithm
- Word Search — #79
- Word Break — #139
- Longest Increasing Subsequence — #300
Interview practice while learning
The six weeks are a topic order, not a waiting period before interviews. After roughly two weeks of basics, start short timed mocks while continuing the roadmap. If you receive an interview invitation sooner, start with the patterns you know and use the remaining time to fix the gaps the mocks reveal. Real interviews, when available, can provide feedback too; you do not need to complete all 46 core questions first.
Begin with these three formats and repeat them with new questions as you learn more:
- From week 2: one array/string or sliding-window problem, 35–40 minutes.
- After tree/graph basics: one tree or graph problem, 35–40 minutes.
- Before an interview: two mixed problems in 45–50 minutes, plus a short project or behavioral discussion.
For every mock, explain the approach before typing, then say why it works, its time and space costs, and the trade-off against another valid approach. After coding, walk through an edge case aloud. If you cannot finish, explain the best approach you have, identify what remains, and test the part you implemented.
After each mock or real interview, write down one or two specific next actions. Check whether the gap was choosing a pattern, proving correctness, a missing concept, edge cases, complexity, implementation, or communication. Revisit the underlying idea, solve a related question, and test yourself again. The outcome of one round is less useful for preparation than the gap it revealed.
JavaScript / Node.js notes
If you plan to interview in JavaScript:
- Use
MapandSetfor frequency and visited-state patterns. - For BFS, use an array plus a head index rather than repeatedly calling
shift()on a large queue. - Use
(a, b) => a - bfor numeric ascending sort; JavaScript’s default sort is lexicographic. - Be comfortable implementing a small binary heap for heap problems if the editor does not provide one.
- Watch for recursion depth and JavaScript number/bitwise behavior on large inputs.
Progress tracker
- Core questions solved independently: ___ / 46
- Missed questions re-solved without notes: ___
- First timed mock completed by week 2: yes / not yet
- Timed mocks completed: ___ (repeat throughout the plan)
- Topics that still need review: ______________________________
- Next specific practice action: ______________________________
Stop condition for a topic: once you can explain and re-solve its patterns, move to mixed questions and mocks. Return to weak topics based on feedback. An interview invitation takes priority over finishing the Core or Stretch checklists.