Available inEnglishFrenchGermanHindiPortugueseRussianSpanish
Coding Interview Patterns (Blind 75)
Read an unfamiliar Blind 75 problem, name the technique it wants and the invariant that makes it correct, before you write a line of code. For candidates who have solved seventy or more LeetCode problems and still freeze on a statement they have not seen; Big-O fluency is assumed, syntax is not taught. Sixty-four cards map ten technique families to the problems that need them.
Given a sorted array, find two entries summing to a target, using O(1) extra space. Name the technique that phrasing points to.
Two pointers converging from both ends
— The sortedness is doing the work a hash map would otherwise do.
Source
Three signals stack up here: the input arrives sorted, the answer is a pair, and the space bound rules out a hash map. Start one index at each end; if the sum is too large move the right one inward, if it is too small move the left one inward. Each step retires an index for good, so the sweep is O(n) with no extra memory. Commonly confused with: the one-pass hash map, which is the right answer when the array is unsorted and space is free, since sorting first would cost an O(n log n) you do not need there.