🪔 Diwali offer: from ₹99 till 8 NovSee prices →

DSA interview questions with solutions for freshers

Updated 20 October 2026 · By Savyly

Ten DSA questions students report from campus coding rounds, with the idea in plain words, time and space complexity, and links to practice problems that have tested Python, C++ and Java code.

Download for Mac 15 free minutes · no card · Windows and Mac

What comes up most

10 questions, the idea and where to practise

  1. Move the empty slots to the end (arrays, two pointers): keep a write marker at the front; copy cars forward, fill the rest with 0. O(N), O(1). Practise on TCS NQT: Move the empty slots to the end.
  2. Find the second-highest score (arrays, one pass): keep the highest and second-highest distinct scores; skip values equal to the highest. O(N). Practise on TCS NQT: Find the second-highest score.
  3. Rotate the display board by K (arrays, modular): reduce K to its remainder after division by N; the value at position i moves to (i+K) mod N. O(N). Practise on TCS NQT: Rotate the display board.
  4. Are two names made of the same letters? (strings, counting): use 26 letter counters, skip spaces and convert the names to lowercase first. O(L). Practise on TCS NQT: Are two names made of the same letters?
  5. Count the pairs that add up to K (hashing): walk once; for each x add the count of K−x seen before. O(N). Practise on Infosys and Accenture: Count the pairs that add up to K.
  6. Fit the most meetings into one room (greedy, sorting): sort by end time; take a meeting if it starts at or after the last end. O(N log N). Practise on Infosys and Accenture: Fit the most meetings into one room.
  7. The best run of days (simple dynamic programming, Kadane): keep the best run that ends today; either extend yesterday’s run or start a new one. O(N). Practise on TCS NQT: The best run of days.
  8. Longest common subsequence (dynamic programming, strings): compare the two prefixes. If their last letters match, extend the result for the shorter prefixes; otherwise take the better result from dropping one letter. O(N×M). Practise on Infosys and Accenture: Longest common subsequence.
  9. Longest increasing subsequence (dynamic programming with binary search): keep the smallest ending value for each length and use binary search to find where each new value belongs. O(N log N). Practise on Infosys and Accenture: Longest increasing subsequence.
  10. Check a password (strings, easy): read the whole line; track whether it contains a digit, an uppercase letter, a lowercase letter or a space, and whether it starts with a digit. O(L). Practise on Infosys and Accenture: Check a password.

More practice with tested code in three languages: TCS NQT, Infosys and Accenture, Wipro, Cognizant GenC and Capgemini.

Practise with Savyly

Questions

Which DSA topics do campus placements ask most?

Arrays and strings, hashing, two-pointers, greedy and simple dynamic programming. The 10 questions above cover each pattern with the idea and complexity.

Where can I practise DSA questions with solutions?

On the practice pages linked above: each problem has the idea in plain words and tested Python, C++ and Java code. Savyly's DSA mode also explains any problem from your screen.

How should I prepare for DSA coding rounds?

Learn one pattern at a time, write the idea in one line before you code, and test edge cases: one element, all equal, empty, and the largest limits. Time yourself, and aim for O(N) or O(N log N) for N up to 10^5.

Does Savyly help with LeetCode and DSA interviews?

Yes. Put a LeetCode, Codeforces or placement problem on your screen, press one key, and Savyly gives the approach, code and complexity. Use /practice for mock coding interviews with feedback.

Download for Mac 15 free minutes · no card · Windows and Mac