How to learn DSA for interviews: the complete roadmap

Which data structures and patterns to learn, in what order, and how far to go for service company tests, higher tiers like TCS Digital or Infosys SP, and product companies. With the best problem lists, how to practise, and how to turn solving into interviewing.

beginner6 min readBy CureBugs EditorialUpdated 5 Nov 2026

Data structures and algorithms decide more interviews than any other topic. The online test at almost every company has at least one coding problem, and the technical interview usually has another. The trouble is that "learn DSA" can mean anything from reversing a string to segment trees, and most people waste weeks on topics their target companies never ask.

This roadmap tells you what to learn, in what order, and where to stop for the job you actually want. It also covers the part most guides skip: getting from "I can solve it" to "I can solve it while someone watches and asks questions".

Decide how far you need to go

Your targetWhat the coding questions look likeStop after
Base tiers at service companies (TCS Ninja, Infosys Systems Engineer, Wipro Elite, Accenture ASE, Cognizant GenC, Capgemini Analyst)Two easy to medium problems in 45 to 90 minutes. Arrays, strings, maths, sorting, simple recursion.Stage 2, with lots of easy practice
Higher tiers (TCS Digital and Prime, Infosys SP and Power Programmer, Wipro Turbo, Accenture Advanced ASE, Cognizant GenC Next)Medium problems, sometimes one hard. Hashing, two pointers, trees, greedy, basic DP and graphs.Stage 4
Product companies and enterprise product roles (Oracle, SAP Labs, Salesforce, startups)Medium to hard, plus follow-ups on complexity and edge cases.Stage 5

If you're not sure, aim one row higher than your first instinct. The extra stages are where offers get better.

Pick one language and stay with it

Use C++, Java or Python. All three are accepted almost everywhere. Choose the one you're most fluent in, not the one that sounds most impressive. What matters:

  • You can read input from standard input and print output without looking anything up. Service company tests usually work this way.
  • You know your language's lists, maps, sets, sorting, heaps (priority queues) and string handling by heart.
  • You know the traps: integer overflow in C++ and Java, recursion limits in Python, and string immutability in Java and Python.

The roadmap

Learn in this order. Each stage builds on the one before, and each pattern links to our guide and to practice problems.

Stage 1: foundations (1 to 2 weeks)

  • Time and space complexity. Be able to say "this is O(n log n) because we sort" without hesitation.
  • Arrays and strings: traversal, reversing, counting, prefix and suffix ideas, in-place updates.
  • Maths: primes, GCD, modular arithmetic, digit manipulation. These turn up in service company tests a lot.
  • Sorting and searching: know how merge sort and quicksort work, and use your language's built-in sort for everything else.
  • Recursion: factorial, Fibonacci, power, and how the call stack works.

Stage 2: the core patterns (2 to 3 weeks)

These patterns cover most easy and medium questions:

Stage 3: trees, heaps and intervals (2 weeks)

  • Binary trees and BSTs: traversals (recursive and iterative), height, diameter, lowest common ancestor, level order.
  • Heaps for top-k and streaming problems: heaps and top-k.
  • Intervals: merging, inserting and scheduling: interval problems.
  • Greedy: when a local choice is provably safe, and how to argue it.

Stage 4: graphs, backtracking and dynamic programming (3 weeks)

  • Graphs: representations, BFS and DFS, connected components, cycle detection, topological sort, shortest paths: graph traversal.
  • Backtracking: subsets, permutations, combinations, N-queens style search: backtracking.
  • Dynamic programming: start with 1D problems (climbing stairs, house robber), then subsequences and 2D grids: DP on subsequences.

Stage 5: depth for product companies

  • Tries, union-find, Dijkstra, bit manipulation.
  • Harder DP (intervals, bitmasks, knapsack variants).
  • Design-flavoured problems like an LRU cache.

Which problem list to follow

You don't need five lists. Pick one and finish it.

  • Striver's A2Z sheet: the sheet most Indian campus candidates use. Very thorough, with videos. Best if you're starting from zero and have two to three months.
  • LeetCode 75: a compact list that covers the core patterns. Best if you have a month.
  • NeetCode roadmap: patterns as a tree, with video explanations. Good for seeing what depends on what.
  • Grind 75: a schedule you can size to the weeks you have.
  • LeetCode patterns: filter problems by pattern to drill one at a time.

For understanding rather than practice, VisuAlgo animates data structures, Abdul Bari's videos explain the classic algorithms clearly, and CP-Algorithms is the reference for anything advanced.

Our own practice problems are grouped by the same patterns, run in Python, Java, C++ and JavaScript against hidden tests, and unlock hints one at a time, so you can drill a pattern right after reading about it.

How to practise so it sticks

  • Time-box each attempt. 25 minutes for an easy problem, 40 for a medium. If you're stuck, take one hint, not the whole solution.
  • Re-solve after three days without looking. If you can't, you memorised it.
  • Write the edge cases first: empty input, one element, all equal, negative numbers, very large inputs.
  • Mix timed sets in the last two weeks: two problems in 60 minutes, just like the online test.
  • Keep a mistakes log. Most people repeat the same three or four mistakes. Write them down and you'll stop.

The step most people skip: solving out loud

In the interview you don't just produce working code. You're expected to:

  1. Clarify the problem and its constraints.
  2. Explain a brute-force idea, then a better one, with complexity.
  3. Code while talking, so the interviewer can follow your thinking.
  4. Test with an example and an edge case.
  5. Handle the follow-up: "what if the array doesn't fit in memory?", "can you do it in O(1) space?"

Candidates who solve 300 problems in silence often freeze at step 2. Read thinking aloud in coding interviews, then practise the whole sequence in a mock coding round. The interviewer asks clarifying questions back, watches your code run against real tests, gives hints only if you ask (and counts them), and follows up the way a real panel would. The report shows whether you lost marks on the solution, the explanation or the testing, which tells you exactly what to practise next.

Mock interview

Solve one like this with an interviewer watching

Getting the answer alone is half the round. The other half is clarifying the problem, explaining your approach, coding while you talk and handling the follow-up. Try it on a problem you haven't seen.

  • A timed problem in a real editor, judged on hidden tests
  • Hints if you ask, and they count against you like they would in the room
  • A scored report that quotes your answers and says what to fix
Start a mock coding round Voice or text. Pause whenever you need to.

Applying somewhere? Start with the company filled in

Go deeper elsewhere

The best material we've found on these topics.

Practise this

Reading builds understanding. Practice makes it stick.

Keep reading

All articles
System design•beginnerStart here

How to learn system design: the complete roadmap

5 min read
DSA patterns•intermediate

Graph traversal: BFS and DFS

15 min read
DSA patterns•intermediate

The backtracking pattern

13 min read