Classic search algorithms from brute force to logarithmic-time binary search.
2 algorithms2 variants2 races9 problems
2 algorithms. Each one builds on the last.
Same input, side by side. Watch who wins.
Searching answers where something is, or whether it is there at all. It opens most interview prep and runs under database indexes and git bisect, which binary searches commits for the one that broke a build.
Every page wins by ruling out candidates without looking at them. Linear search rules out one item per check; binary search uses sorted order to rule out half of what is left. The two pointer problems rule out a batch of pairs per move: once the shorter wall in Container With Most Water moves in, every pair that used it is gone, since none could hold more water.
The five two pointer problems sit with the searches because each one is a search over pairs or positions that throws most of them away unchecked. The method itself is taught on the Two Pointers page in Array Techniques, beside Valid Palindrome, so read that page first. Trapping rain water and container with most water use its inward walk, move zeroes and remove duplicates use read and write pointers, and sort colors adds a third.