Fifty seconds for one dispute.
transcript
Find two payments that add up. A correct search can still fail. Count the checks first. A payments app met this on a real night.
A batch holds a hundred thousand payments. A merchant disputes one total. Which two payments make it? Support needs the two positions. The answer must come fast.
Try every pair of payments. Stop when the sum matches. It is correct, and short. You write it first, and it works. The team keeps it as the reference. It checks every faster version.
There are five billion pairs. At a hundred million a second, fifty seconds. Three hundred disputes a night: four hours. The report cannot finish by morning. A faster machine would not help. We need fewer checks.
A map remembers what you read. One lookup finds the partner. The data is the same. The method changed. Each payment asks one question. Is my partner already in the map?
Count before you build. Full breakdown in the lecture.