Workspace Interview Prep
0d
QUIIKTOOL DSA

DSA Interview Preparation

Prepare for coding interviews with pattern-based DSA questions, approaches, complexity and edge cases.

Frame the problem

Make requirements testable before committing to a technique.

What does a pair mean?Ask whether the two indices must differ, whether duplicate values are allowed and whether any solution is acceptable. For [4] and target 8, two distinct indices cannot form an answer.
Which constraints change the design?State maximum input size, value range, sortedness, allowed mutation and memory limits. Sorting can destroy the positions that an index-returning problem asks for.
How do I state a baseline?Describe the simplest complete search. For pair sum, enumerate i < j. There are n(n−1)/2 comparisons; this gives you a correct reference for small tests.

Explain an optimization

Move from repeated work to an invariant an interviewer can check.

Where is the repeated work in pair sum?Each inner scan asks whether the complement exists. In one pass, store the earlier values so each new candidate can query its complement. Check before insertion.
How can I justify a pointer move?In sorted pair sum, if the endpoints sum too low, the left value is too small even with the largest available partner. Every pair beginning at that index can be discarded.
What should a complexity claim include?Name the size variable and the work per unit. Hash lookup is expected constant time under suitable hashing. A one-pass complement map has expected O(n) time and O(n) auxiliary memory.

Test and discuss a follow-up

Close the explanation with a trace and one change that would alter the answer.

Which boundary inputs would I show?Try an empty collection, one element, repeated values, a missing target and a target at the final index. State the agreed return convention before recording outputs.
What if input arrives as a stream?A prefix frequency map can be maintained as values arrive. Sorting an entire unfinished stream would require buffering it. Ask how long earlier values must remain available.
How should I handle uncertainty?Write the invariant in words, run the smallest case that could break it, and explain any correction. Distinguish a proved claim from an intuition you are still testing.

Hashing

Practice relevant to general Amazon, Microsoft and Google software engineering interviews; exact question occurrences are not verified.

Count subarrays with sum kUse prefix frequencies initialized with 0:1; query prefix minus k before inserting. Expected O(n).
Group anagramsGroup by sorted string or frequency signature.

Two pointers and windows

Practice relevant to general Amazon, Microsoft and Google software engineering interviews; exact question occurrences are not verified.

Three sumSort, fix one index, sweep two endpoints, skip duplicates. O(n²).
Minimum covering substringTrack required multiplicities; shrink when all requirements are met.

Binary search

Practice relevant to general Amazon, Microsoft and Google software engineering interviews; exact question occurrences are not verified.

Minimum shipping capacitySearch between largest weight and total weight using monotone feasibility.
Rotated sorted array searchIdentify sorted half and discard the half that cannot contain target.

Graphs

Practice relevant to general Amazon, Microsoft and Google software engineering interviews; exact question occurrences are not verified.

Course schedulingKahn algorithm; fewer than V processed nodes implies a cycle.
Count islandsBFS or DFS from unvisited land, marking on discovery.
Redundant connectionUnion-find detects edges joining vertices already connected.

Dynamic programming

Practice relevant to general Amazon, Microsoft and Google software engineering interviews; exact question occurrences are not verified.

Longest increasing subsequenceMaintain minimum tails using lower bound. O(n log n).
Equal subset partitionReject odd totals; use descending-capacity 0/1 subset sum.

Stacks and heaps

Practice relevant to general Amazon, Microsoft and Google software engineering interviews; exact question occurrences are not verified.

Largest histogram rectangleUse increasing stack of indices and flush at end.
Streaming medianMaintain two balanced heaps with ordered halves.

Pause and Predict

Pause a binary search before the boundary update and predict its next interval.

Find 19 in the sorted array. The current midpoint is index 3.

  1. 20
  2. 51
  3. 72
  4. 11probe 3
  5. 144
  6. 195
  7. 236

Which action should the search take now?