DSA Roadmap for Beginners: How to Start From Zero and Get Interview-Ready

By Preeti Verma

Data structures and algorithms (DSA) scares many beginners. The lists of problems are endless, the advice contradicts itself, and it is hard to know whether you are making progress.

This roadmap gives you a clear order. You will learn what to study first, how long each stage takes, how to practise so that the knowledge sticks and when you are ready to start interview-style problems. No special talent is needed, only a plan and steady practice.

Why DSA matters

Coding interviews at many companies test it, and it trains a habit that is useful in real work: breaking a problem into steps, choosing the right structure and thinking about cost. Not every job needs deep DSA, and many service roles stop at basics, while product companies go deeper. Either way, the foundation is the same.

Before you start

  • Know one programming language reasonably well: loops, functions, lists, maps and strings. If not, spend a few weeks on that first. Our Python roadmap and Java vs Python guide can help you choose and start.
  • Pick one language for DSA and stay with it.
  • Decide a daily time slot, even 60 to 90 minutes.

The roadmap in order

Stage 1: Big O notation (week 1)

Learn how to describe how the cost of an algorithm grows as the input grows: O(1), O(log n), O(n), O(n log n) and O(n squared). You do not need the maths, only the intuition: a loop is usually O(n), a loop inside a loop is O(n squared), halving each step is O(log n). Quote complexity for every solution from now on.

Stage 2: arrays and strings (weeks 2 and 3)

The foundation of most problems. Learn traversal, reversing, finding maximum and minimum, counting, in-place changes and basic string manipulation. Practise on easy problems until they are comfortable. Use our top 50 coding questions as your list.

Stage 3: hashing (week 4)

Hash maps and sets give you fast lookups, and they are the key to solving a huge number of problems: counting frequencies, finding duplicates, Two Sum, grouping anagrams. After this stage, you will notice that many "slow" solutions become fast.

Stage 4: two pointers and sliding window (weeks 5 and 6)

Two techniques that turn O(n squared) problems into O(n). Use two pointers on sorted arrays and for pairs, and a sliding window for subarray and substring problems with a condition (longest substring without repeating characters, for example).

Stage 5: sorting and binary search (weeks 6 and 7)

Understand bubble, selection and insertion sort for learning, merge sort and quick sort for efficiency, and know how to use the built-in sort. Learn binary search properly, because it appears in many forms: searching in a sorted array, finding a boundary, and searching on an answer.

Stage 6: stacks and queues (week 8)

Learn how each works and when to use them. Typical problems: valid parentheses, next greater element, and implementing a queue with two stacks. Add a quick look at monotonic stacks.

Stage 7: linked lists (week 9)

Learn node-based structures and the pointer techniques: reversing, finding the middle with slow and fast pointers, detecting cycles and merging sorted lists. Draw them on paper before coding.

Stage 8: recursion and backtracking (weeks 10 and 11)

Recursion means a function that calls itself with a smaller problem. Learn base cases, the call stack and how to trace a recursive call. Then backtracking: generating subsets and permutations by making a choice, exploring, and undoing it. These feel hard at first, and drawing the recursion tree helps a lot.

Stage 9: trees (weeks 12 and 13)

Binary trees, traversals (inorder, preorder, postorder, level order), height, and binary search trees. Most tree problems are solved with recursion or a queue. Learn the standard patterns well.

Stage 10: heaps and priority queues (week 14)

Used for "top k" problems and scheduling. Learn what a heap gives you (fast access to the smallest or largest item) and how to use your language's built-in version.

Stage 11: graphs (weeks 15 and 16)

Represent a graph with an adjacency list, and learn breadth-first search (shortest path in unweighted graphs) and depth-first search (exploring and cycle detection). Typical problems: number of islands, connected components, and simple topological ordering.

Stage 12: dynamic programming (after week 16, ongoing)

Leave this for last, because it builds on recursion and arrays. Start with the simplest problems (climbing stairs, Fibonacci), learn memoisation and then the table method. Our dynamic programming guide for beginners gives a simple method that works. Give it time. Many people need weeks of practice before it clicks.

A sixteen-week plan

  • Weeks 1 to 3: Big O, arrays and strings. 5 problems a week minimum.
  • Weeks 4 to 7: hashing, two pointers, sliding window, sorting and binary search. 7 to 10 problems a week.
  • Weeks 8 to 11: stacks, queues, linked lists, recursion. 7 to 10 problems a week.
  • Weeks 12 to 16: trees, heaps and graphs. 7 to 10 problems a week.
  • After: dynamic programming and mixed practice through the patterns in our DSA patterns guide.

If you study part-time, stretch each stage. The order matters more than the speed.

How to practise so it sticks

  1. Try for 20 to 30 minutes before looking at hints. Struggling is where learning happens.
  2. If you are stuck, read a hint, not the full solution. Then try again.
  3. After solving, write down the pattern in one sentence: "This was a sliding window because..."
  4. Revisit failed problems after two or three days, and again after a week.
  5. Write code by hand sometimes. It builds understanding and helps in interviews without an IDE.
  6. State time and space complexity for every solution.
  7. Keep a notebook or a file of patterns and your mistakes.

Quality beats quantity. Fifty problems understood deeply teach more than 300 copied solutions.

How to explain your solution

In interviews you must think aloud:

  1. Repeat the problem and ask about edge cases.
  2. Describe a simple solution and its cost.
  3. Improve it and say why.
  4. Write the code while explaining.
  5. Test it on an example and an edge case.
  6. State the final complexity.

Practising this aloud is a separate skill from solving silently. The GenQuest AI mock interview lets you explain solutions to an interviewer that asks follow-up questions.

When to start interview-style problems

After stage 6 or 7, mix in problems from interview lists. Move to the Blind 75 and NeetCode 150 in the patterns guide once you can solve most easy problems and some medium ones without help.

How much DSA do you need?

  • Many service-company fresher tests: arrays, strings, hashing, sorting, basic recursion and simple data structures.
  • Product companies: everything above, plus trees, graphs, heaps and dynamic programming, at medium level and sometimes harder.
  • Your own career: enough to reason about cost and choose the right structure in daily work.

Check the stage requirements of the companies you target. See our guide to company-specific preparation and the switch from service to product guide.

Common mistakes

  1. Jumping to hard problems early. Build the base first.
  2. Reading solutions immediately. Struggle first.
  3. Solving each problem once and never revisiting it.
  4. Memorising code instead of patterns.
  5. Switching languages or platforms constantly.
  6. Ignoring complexity.
  7. Burning out. A steady hour a day beats a weekend of ten hours.

A worked example: the sliding window pattern

Sliding window is one of the most useful patterns, so it is worth seeing once in full. The problem: find the length of the longest substring of a string that has no repeating characters. For "abcabcbb" the answer is 3 ("abc").

Brute force: check every substring and test whether it has duplicates. That is O(n cubed) if done naively, which is far too slow.

The idea: keep a window from start to the current index. Move the right end forward one character at a time. If the new character is already inside the window, jump the left end past its previous position. The window always holds only unique characters.

def length_of_longest_substring(s):
    last_seen = {}
    start = 0
    best = 0
    for i, ch in enumerate(s):
        if ch in last_seen and last_seen[ch] >= start:
            start = last_seen[ch] + 1
        last_seen[ch] = i
        best = max(best, i - start + 1)
    return best

Trace on "abcabcbb": the window grows to "abc" (length 3). At the second a, the old a is inside the window, so start moves to index 1. The window becomes "bca", still length 3. The same happens at each repeat, and the best length stays 3. At the end the function returns 3.

Complexity: each character is visited once, so O(n) time, and the map holds at most one entry per distinct character, so O(k) space, where k is the size of the character set.

Once you understand why this works, you can recognise the same shape in other problems: the longest subarray with a given property, the smallest window that contains something, or the maximum sum of k consecutive elements.

A simple progress tracker

Tracking prevents the feeling that you are not improving. Keep one file with a row per problem:

  • Problem name and link.
  • Topic or pattern.
  • Date solved.
  • Result: solved alone, solved with a hint or could not solve.
  • Time taken.
  • The key idea in one sentence.
  • Revisit date.

Review the file every Sunday. Count how many problems you solved alone this month compared with last month, and look at which patterns appear most in the "could not solve" rows. That tells you what to study next, and the revisit column makes sure you return to problems when they are about to fade from memory.

When you feel stuck for days

Everyone hits a wall, often around recursion or dynamic programming. When it happens, step back instead of pushing harder. Go back to easier problems on the same topic, trace a solution by hand with a small example, draw the recursion tree or the table, and read one clear explanation. Then return to the hard problem after a day. Struggling is normal, and the wall almost always gives way after a few focused sessions.

Frequently asked questions

How long does it take to learn DSA?

Around four months of steady practice to cover the core topics, and longer to feel confident on medium and hard problems. Everyone's pace differs.

Which language is best for DSA?

The one you know best. Python is concise, Java and C++ are common in interviews, and all are accepted by most companies.

Do I need DSA for every job?

No, but it appears in many interviews and teaches useful thinking. Check what your target companies test.

Where should I practise?

Any coding platform with topic filters and a decent community works. What matters is practising consistently with a list, not the site itself.

The takeaway

Learn DSA in order: Big O, arrays and strings, hashing, two pointers and sliding window, sorting and binary search, stacks, queues, linked lists, recursion, trees, heaps, graphs and then dynamic programming. Practise daily, revisit your mistakes and explain solutions aloud. In about four months you will move from "I cannot start" to solving real interview problems.