All categories
DSA Interview Questions
Patterns, proofs and complexity — from brute force to the optimal solution.
4 of 4 questions
Topic
Difficulty
Frequency
Round
Type
BeginnerAsked very oftenArrays & HashingCoding round · Coding
Two Sum: from brute force to a one-pass hash map
The gateway question: replace the nested loops with a hash map and turn the search inside out in one pass.
arrayshash-mapcomplexity
AdvancedAsked very oftenCaching & DesignSystem design · Design
Design an LRU cache with O(1) get and put
Everything hinges on one design move: a hash map to find the node and a doubly linked list to reorder it, both in constant time.
lrucachehash-map
IntermediateAsked sometimesLinked ListsCoding round · Coding
Floyd's cycle detection: slow, fast, then reset
Two pointers, no extra memory: the fast one laps the slow one inside a cycle, and one reset finds exactly where the loop begins.
linked-listtwo-pointerscycle-detection
AdvancedAsked sometimesStringsCoding round · Coding
KMP: linear-time substring search with LPS
Naive search rewinds the text pointer on every mismatch; KMP precomputes a failure table so the text is read once and never revisited.
stringskmppattern-matching