DSA Interview Questions

60 DSA interview questions with worked answers, complexity notes, and runnable code you can edit in the browser — ordered easy to hard so you build up steadily. Free, no signup. Open any question for the full answer.

Method beats memorization

Frontend DSA rounds are rarely about exotic algorithms. They lean easy-to-medium — arrays, strings, hash maps, trees, and usually one design-flavored problem — and what gets scored is not whether you produce the optimal answer but how you get there. Interviewers are watching a process, and the candidates who pass make that process visible every time.

The sequence is always the same. First clarify: what are the inputs, how big can they get, what are the edge cases, can the input be empty or contain duplicates? Then state the brute-force solution and its Big-O out loud, before optimizing — this proves you understand the problem and gives you a baseline to improve on. Then name the pattern. Most interview problems are one of a handful in disguise: two pointers, sliding window, a hash map for O(1) lookup, binary search on a sorted space, breadth-first or depth-first traversal, or a heap for top-k. Recognizing which one applies is most of the battle, and it is a skill you build by pattern, not by grinding hundreds of problems.

Only then do you code — cleanly, with names a reader can follow — and finish by dry-running one normal example plus the edge cases you named at the start. Complexity gets discussed in terms of both time and space, because the trade-off between them is often the actual question. The decision table on this page exists to short-circuit the hardest step: map the shape of the input to the pattern before you write a line. These questions give you the reps to make that mapping automatic.

Easy

Medium

Hard

Other topics

HTML/CSS · Browser · JavaScript · TypeScript · React · System Design · Accessibility · Web Performance · Testing · Networking/Security

← Search all 265 questions