The DSA Roadmap: What to Study, In What Order, and Why
A practical roadmap for learning data structures and algorithms -- the right order, time estimates, key patterns, and how to know when you're interview-ready.
Everyone tells you to "learn DSA." Nobody tells you what to study first, what to skip, or how to tell when you actually know enough. This is the roadmap I wish someone had handed me before I spent three months studying the wrong things in the wrong order.
Why DSA Matters (and Not Just for Interviews)
Let's get the obvious one out of the way: most tech companies ask DSA questions in interviews. FAANG, startups, mid-size companies -- if you're interviewing for a software engineering role, you're going to face these problems. That's reason enough to learn them.
But here's the thing people don't talk about: DSA knowledge makes you a better engineer even outside interviews.
When you understand hash maps deeply, you don't write O(n^2) nested loops to check for duplicates -- you do it in O(n) without thinking. When you understand trees, working with the DOM, file systems, or org charts feels intuitive. When you understand graph traversal, you can model and solve problems that would otherwise seem impossibly complex.
DSA isn't academic busywork. It's the vocabulary of efficient problem-solving. The interview prep is just a forcing function to actually learn it.
The Roadmap: Study in This Order
This order is intentional. Each topic builds on the ones before it. Skipping ahead usually means you'll get stuck and have to come back anyway.
Phase 1: Foundations (Weeks 1-3)
Arrays and Strings
Start here. Arrays are the most fundamental data structure, and strings are essentially arrays of characters. Almost every other topic builds on your ability to manipulate arrays fluently.
What to learn:- Traversal, insertion, deletion
- Two-pass and single-pass patterns
- In-place modification vs. creating new arrays
- String manipulation: reversal, substring search, character frequency
- Common patterns: counting, finding min/max, checking conditions
- Two Sum
- Best Time to Buy and Sell Stock
- Valid Anagram
- Merge Sorted Array
- Reverse String
Don't rush this. If you can't comfortably solve medium-difficulty array problems, everything that follows will feel harder than it needs to be.
Hash Maps and Sets
Hash maps (dictionaries in Python, objects/Maps in JavaScript) are arguably the most important data structure in practical programming. They give you O(1) lookups and are the backbone of countless patterns.
What to learn:- How hash maps work internally (hash function, collision handling)
- When to use a hash map vs. a set vs. an array
- Frequency counting pattern
- Two-pass hash map pattern
- Grouping and categorizing with hash maps
- Two Sum (yes, again -- with a hash map this time)
- Group Anagrams
- Contains Duplicate
- Valid Sudoku
- Longest Consecutive Sequence
After arrays and hash maps, you can already solve a surprising number of interview problems. These two alone cover probably 30% of what you'll encounter.
Phase 2: Core Patterns (Weeks 4-7)
Two Pointers
The two-pointer technique is a pattern for processing arrays and strings efficiently. Instead of nested loops (O(n^2)), you use two pointers moving through the data in a coordinated way (O(n)).
What to learn:- Pointers moving toward each other (left/right)
- Pointers moving in the same direction (slow/fast)
- Using two pointers on sorted arrays
- Partitioning arrays
- Valid Palindrome
- Two Sum II (sorted array)
- 3Sum
- Container With Most Water
- Remove Duplicates from Sorted Array
Sliding Window
Sliding window is for problems involving contiguous subarrays or substrings. Instead of checking every possible subarray (O(n^2)), you "slide" a window across the array (O(n)).
What to learn:- Fixed-size window
- Variable-size window (expand and contract)
- When to shrink vs. expand the window
- Tracking window contents with a hash map
- Maximum Subarray
- Longest Substring Without Repeating Characters
- Minimum Window Substring
- Permutation in String
- Sliding Window Maximum
Stacks and Queues
Stacks (LIFO) and queues (FIFO) are simple but show up constantly. Stacks especially are the backbone of parsing, expression evaluation, and a pattern called "monotonic stack" that appears in many problems.
What to learn:- Stack operations and when to use them
- Queue operations and when to use them
- Matching/balancing problems (parentheses, brackets)
- Monotonic stack pattern
- Using a stack to track state during iteration
- Valid Parentheses
- Min Stack
- Daily Temperatures
- Evaluate Reverse Polish Notation
- Implement Queue using Stacks
Phase 3: Recursion and Trees (Weeks 8-11)
Recursion and Backtracking
Recursion is a technique, not a data structure, but you need to be comfortable with it before tackling trees, graphs, and dynamic programming. Backtracking is a specific recursive pattern for exploring all possible solutions.
What to learn:- Base case and recursive case
- The call stack and how recursion uses memory
- Drawing recursion trees to visualize execution
- Backtracking: explore, choose, unchoose
- Pruning branches to optimize
- Fibonacci (understand the naive vs. memoized versions)
- Subsets
- Permutations
- Combination Sum
- N-Queens
This is where many people hit a wall. Recursion requires a different way of thinking. If it doesn't click immediately, that's normal. Draw the recursion tree for every problem. Trace through small inputs by hand.
Binary Trees
Trees are everywhere: file systems, the DOM, database indexes, compiler parse trees. Binary trees specifically are the gateway to understanding all tree-based data structures.
What to learn:- Tree terminology (root, leaf, height, depth, level)
- DFS traversals: inorder, preorder, postorder
- BFS traversal (level-order)
- Recursive vs. iterative traversal
- Binary Search Trees (BST) and their properties
- Maximum Depth of Binary Tree
- Invert Binary Tree
- Same Tree
- Lowest Common Ancestor
- Validate Binary Search Tree
- Binary Tree Level Order Traversal
Heaps and Priority Queues
A heap is a tree-based structure that gives you efficient access to the minimum or maximum element. Priority queues are built on heaps and are essential for problems involving "top K" elements or scheduling.
What to learn:- Min-heap vs. max-heap
- Insert and extract operations (O(log n))
- Building a heap from an array (O(n))
- Using a heap for "top K" problems
- Two-heap pattern (for finding medians)
- Kth Largest Element in an Array
- Top K Frequent Elements
- Merge K Sorted Lists
- Find Median from Data Stream
- Task Scheduler
Phase 4: Graphs (Weeks 12-14)
Graph Fundamentals
Graphs generalize trees. Where a tree has a root and no cycles, a graph can have any structure -- cycles, disconnected components, weighted edges. A huge number of real-world problems are graph problems in disguise.
What to learn:- Graph representations: adjacency list vs. adjacency matrix
- Directed vs. undirected graphs
- Weighted vs. unweighted graphs
- BFS (breadth-first search) -- best for shortest path in unweighted graphs
- DFS (depth-first search) -- best for exploring all paths, detecting cycles
- Connected components
- Number of Islands
- Clone Graph
- Course Schedule (cycle detection)
- Pacific Atlantic Water Flow
- Word Ladder (BFS)
- Number of Connected Components
Advanced Graph Algorithms
Once you're comfortable with basic BFS and DFS, these algorithms extend your toolkit for specific graph problems.
What to learn:- Topological sort (ordering tasks with dependencies)
- Dijkstra's algorithm (shortest path in weighted graphs)
- Union-Find / Disjoint Set (grouping connected components efficiently)
- Minimum spanning tree (Kruskal's, Prim's) -- lower priority for interviews
- Course Schedule II (topological sort)
- Network Delay Time (Dijkstra's)
- Redundant Connection (Union-Find)
- Accounts Merge
Phase 5: Dynamic Programming (Weeks 15-18)
DP Fundamentals
Dynamic programming scares people more than it should. At its core, DP is just recursion with memory -- you solve subproblems and cache their results so you don't redo work.
What to learn:- Identifying overlapping subproblems
- Memoization (top-down DP)
- Tabulation (bottom-up DP)
- 1D DP problems
- 2D DP problems (grids, two-sequence problems)
- State definition: what does
dp[i]represent?
- Climbing Stairs
- House Robber
- Coin Change
- Longest Increasing Subsequence
- Word Break
- Unique Paths
- Longest Common Subsequence
- Edit Distance
- 0/1 Knapsack
- Longest Palindromic Substring
DP is the hardest topic on this list. Give it more time than you think you need. The key insight is always the same: figure out the subproblem structure and the recurrence relation. Everything else follows.
Common DP Patterns
Once you've solved 15-20 DP problems, you'll start recognizing these recurring patterns:
- Linear DP --
dp[i]depends on previous elements: Climbing Stairs, House Robber - Interval DP --
dp[i][j]represents a range: Longest Palindromic Substring - Knapsack -- include/exclude decisions with a capacity constraint
- String DP --
dp[i][j]compares two sequences: Edit Distance, LCS - Decision DP -- at each step, make a choice that affects future options
The Time Commitment
Let's be honest about timelines. Here's what's realistic:
| Phase | Topics | Duration |
|---|---|---|
| 1. Foundations | Arrays, Strings, Hash Maps | 2-3 weeks |
| 2. Core Patterns | Two Pointers, Sliding Window, Stacks | 3-4 weeks |
| 3. Trees | Recursion, Binary Trees, Heaps | 3-4 weeks |
| 4. Graphs | BFS/DFS, Topological Sort, Dijkstra | 2-3 weeks |
| 5. Dynamic Programming | 1D DP, 2D DP, DP Patterns | 3-4 weeks |
If you're doing this full-time, you can compress it to 6-8 weeks. If you're studying part-time on top of a job, budget 4-5 months.
These timelines assume you're solving problems as you go, not just reading about them. Reading about arrays without solving problems is like reading about swimming without getting in the pool.
How to Actually Practice
The problem-solving process
For every problem, follow this sequence:
- Read the problem. Understand it. Don't start coding until you can explain the problem in your own words.
- Think about the approach. What data structure fits? What pattern does this look like? Start with brute force, then optimize.
- Code it. Write the solution without looking at hints.
- Test it. Walk through your solution with the examples. Check edge cases.
- Analyze complexity. What's the time and space complexity?
How many problems?
You don't need to solve 500 LeetCode problems. Quality matters more than quantity.
- 100-150 problems covering all the topics above is enough for most interviews
- Focus on understanding patterns, not memorizing solutions
- Solving 5 problems from a single pattern is better than solving 20 random problems
- Re-solve problems you found hard after a week -- if you can't solve them again, you didn't actually learn the pattern
Spaced repetition
When you solve a problem, mark it as:
- Easy -- solved it quickly, understood the approach
- Medium -- solved it with some effort
- Hard -- needed hints or couldn't solve it
Review hard problems after 3 days. Review medium problems after a week. If a hard problem becomes medium, review it again after 2 weeks. This is spaced repetition applied to DSA, and it's dramatically more effective than solving new problems every day.
Resources
For learning the concepts:
- "Grokking Algorithms" by Aditya Bhargava -- best visual introduction to algorithms
- MIT OpenCourseWare 6.006 -- excellent free lectures on algorithms
- NeetCode's roadmap -- curated problem sets organized by pattern
- Abdul Bari's YouTube channel -- clear algorithm explanations
For practice:
- LeetCode -- the standard platform. Start with the "Blind 75" list, then "NeetCode 150"
- HackerRank -- good for fundamentals and learning the basics
- CodeUp -- structured practice with real-world context
For reference:
- Big-O Cheat Sheet (bigocheatsheet.com) -- quick reference for time/space complexity
- Visualgo (visualgo.net) -- animated visualizations of algorithms and data structures
How to Know When You're Ready
This is the question everyone asks and nobody answers clearly. Here are concrete signals:
You're ready for interviews when:- You can solve most Easy problems in under 15 minutes
- You can solve most Medium problems in under 30 minutes
- You can identify which pattern a problem uses within the first few minutes
- You can analyze time and space complexity without thinking hard about it
- You can explain your approach before writing code
- You've solved at least 100 problems across all the categories above
- You can solve problems you've seen before but get stuck on new ones
- You can code solutions but can't explain why they work
- You skip the brute-force approach and try to jump to optimal immediately
- You've only practiced one or two categories and ignored the rest
Common Mistakes
Solving random problems. Without structure, you'll solve 200 problems and still feel unprepared. Follow a roadmap (this one, NeetCode 150, Blind 75 -- pick one and stick with it). Reading solutions too quickly. Struggling is where learning happens. If you look at the solution after 5 minutes, you're robbing yourself of the struggle that builds understanding. Skipping the fundamentals. If you jump to DP without being solid on arrays and recursion, you'll spend 3 hours on a problem that would take 30 minutes with better foundations. Only doing easy problems. Easy problems build confidence but don't prepare you for interviews. Most interview questions are medium difficulty. You need to be comfortable being uncomfortable. Not coding by hand. In interviews, you often can't rely on autocomplete and syntax highlighting. Practice writing code in a plain editor occasionally. Ignoring time and space complexity. Every interview will ask "what's the complexity?" If you can't answer this for your own solution, you haven't fully understood it.The Meta-Skill
Here's the real secret: DSA isn't about knowing algorithms. It's about problem decomposition -- the ability to take a complex problem, break it into smaller subproblems, choose the right tools to solve each one, and combine the results.
Once you've internalized the patterns, you stop thinking "this is a sliding window problem" and start thinking "I need to efficiently track a contiguous range" -- and the technique just shows up naturally. That's when you know the learning has stuck.
Start the roadmap today. Phase 1 is just arrays and hash maps -- stuff you probably already half-know. Build momentum with the fundamentals, and the harder topics become much more approachable.
Practice consistently with structured problems on CodeUp -- working through these topics in order with real problems is the fastest way to build the pattern recognition that makes DSA click.