DSA Interview Guide
Learn how strong engineers approach algorithmic problems — and how to recognize good and bad problem-solving strategies.
Only have 10 minutes?
Three questions that expose how someone thinks. Read the strong answer, then check yourself against the flags.
“Given an array and a target, how would you determine which algorithmic approach to use?”
- · Whether the candidate interrogates the input before reaching for an algorithm.
- · Whether they can map concrete properties (sorted, bounded, positive-only) to concrete techniques.
- · Whether they use constraints (
n) to decide which complexity is acceptable. - · Whether they think in terms of a decision procedure rather than recalling one memorized problem.
“Your first solution is O(n²). How would you determine whether it can be improved?”
- · Whether the candidate has a repeatable optimization procedure rather than a bag of tricks.
- · Whether they can locate the bottleneck (the inner loop) and characterize what it computes.
- · Whether they know lower-bound reasoning: some problems are genuinely quadratic in output size.
- · Whether they reason about redundant work: recomputation, repeated scans, repeated lookups.
“How do you decide between BFS, DFS, Dijkstra, and Dynamic Programming?”
- · Whether the candidate sees these as answers to different questions rather than interchangeable tools.
- · Whether they know the precise precondition of each (unweighted, non-negative weights, acyclic subproblem graph).
- · Whether they can recognize that DP is shortest path on a DAG, and BFS is Dijkstra with unit weights.
- · Whether they can state complexity in terms of
VandE.
The central loop
Every question, problem and assessment here rewards this process — not memorized names.
- Problem→
- Clarify→
- Constraints→
- Brute Force→
- Bottleneck→
- Pattern→
- Algorithm→
- Complexity→
- Code→
- Test→
- Improve
Skill levels
Click a level to see expected knowledge, example questions, required patterns, typical mistakes and what to learn next.
- Recognizes common patterns from problem phrasing: contiguous subarray → sliding window, sorted pairs → two pointers, nearest greater → monotonic stack.
- Comfortable with binary search, two pointers, sliding window, BFS/DFS, heaps, and basic 1D/2D DP.
- Explains time and space complexity, including recursion stack and the cost of auxiliary structures.
- Optimizes a brute force by naming the redundant work and replacing it with the right structure.
- Handles edge cases systematically rather than on request: empty, single, all equal, extremes.
- The two binary-search templates and binary search on the answer with a monotonic feasibility check.
- Sliding window invariants and why negative numbers break sum-based windows.
- BFS for shortest paths on unweighted graphs; DFS for reachability, components, and cycle detection.
- Heap operations, top-
Kwith a size-Kmin-heap, and theO(n log k)bound. - Prefix sums and the prefix-plus-hash-map idiom for subarray sum problems.
- Memoization versus tabulation, and defining the state before writing a transition.
- Sorting complexities and stability; when sorting unlocks two pointers.
- Amortized analysis for dynamic arrays and monotonic stacks.
- Applies a pattern by resemblance without checking its precondition (unsorted two pointers, non-monotone window).
- Uses DFS for shortest paths or Dijkstra for unweighted graphs.
- Defines a DP transition without a clear meaning for the state.
- Reports
O(n)for a monotonic stack "because it is usually fast" instead of the push/pop argument. - Optimizes constants when the asymptotic bound is the problem, or vice versa.
Tier 1 — Fundamentals
Questions that test whether someone understands the basic mechanics of algorithms and data structures.
Tier 2 — Algorithmic Pattern Recognition
These questions test whether someone can recognize the underlying structure of a problem instead of blindly trying algorithms.
Tier 3 — Advanced Algorithms & Systematic Reasoning
Deeper understanding: branching decisions, DP state design, greedy vs DP, correctness.
Green flags · Red flags
The lens used across the entire guide.
- Clarifies requirements before solving
- Checks constraints and derives an acceptable complexity
- Starts with brute force, then names the bottleneck
- Derives the optimization instead of recalling it
- Explains time and space complexity
- Discusses tradeoffs and alternatives
- Tests edge cases deliberately
- Explains why the algorithm is correct
- Immediately writes code
- Memorizes an algorithm without explaining why it applies
- Ignores constraints
- Says "this is the fastest" without analysis
- Cannot explain complexity or correctness
- Uses advanced structures unnecessarily
- Optimizes before understanding the problem
- Ignores edge cases
Practice modes
The interview flow
Mock interviews walk you through these stages and highlight where you are.
- 1Problem→
- 2Clarifying Questions→
- 3Constraints→
- 4Brute Force→
- 5Complexity Analysis→
- 6Pattern Recognition→
- 7Optimized Solution→
- 8Implementation→
- 9Testing→
- 10Follow-Up→
- 11Evaluation