← Practice
Core Patterns
Two pointers, sliding window, binary search on the answer, heaps, and interval merging. Almost every coding-round question is one of these wearing a costume, and the goal here is to recognise the shape in the first two minutes rather than to memorise solutions.
6 questions
- Find a pair summing to a target, in a sorted arrayThe two-pointer pattern in its smallest useful form. The point is not the answer; it is being able to say why the pointers never miss a pair.easyWrittenExplain to unlock#arrays#two-pointers15 min
- Longest run of distinct elementsSliding window with a "last seen" map. The trap is the pointer that moves backwards.mediumWrittenExplain to unlock#hash-map#sliding-window#strings25 min
- Merge overlapping intervalsSorting by start, then one pass. Most of the marks are in how you define "overlapping".mediumWritten#greedy#intervals#sorting20 min
- Kth largest in a streamA min-heap of size k. The counter-intuitive part is that you keep the *smallest* elements at the top.mediumWritten#heap#streaming#top-k20 min
- Search a rotated sorted arrayBinary search where one half is always still sorted. Finding which half is the entire question.mediumWrittenExplain to unlock#arrays#binary-search25 min
- Fewest machines to finish by a deadlineBinary search on the answer. Recognising that the question is monotonic is the whole insight.hardWrittenExplain to unlock#binary-search#greedy#optimisation30 min