Searching & Two PointersHalving the search space
From plain linear search, to binary search over sorted data, to two pointers and sliding windows — the two array techniques that turn O(n²) into O(n). This is the highest-frequency toolkit in both interviews and day-to-day work.
Why learn Searching & Two Pointers
Where it shows upWhich of a thousand commits introduced the bug? Test the middle one each time and ten steps is enough. That is binary search, and it works on anything ordered.
→ Lesson: Binary SearchKoko eating bananas, the minimum ship capacity: the answer itself is monotonic — faster always still makes it — so you can binary search the answer and just check feasibility each time.
→ Lesson: Binary Search on AnswerData keeps arriving and the window keeps sliding. A sliding window adds each value once and removes it once, instead of recomputing the whole range.
→ Lesson: Sliding WindowOne pointer from each end, closing in. That drops a factor of n versus the nested loop, and a lot of array problems are variations on it.
→ Lesson: Two Pointers