One per match undercounts
transcript
A sweep finds a match. Do you add one to the count? It feels natural, and it is wrong. A thousand segments would hide the problem. Small cases show it. Here is why that fails.
Add one per match, and the sweep counts only four triangles. Add the high minus the low pointer. Now the answer is seven.
One match hides many valid pairs. Every smaller segment also fits. Count them all in one step.
Four zeros should give four triples of positions. One per match counts only two. Count the pairs inside each run.
Ask what a match stands for, before you write the count. If it is a block, count the whole block. Add the size of the block, then test the equal values too.
A match can stand for many answers. Count the block, not one. Then test the case with equal values. Full breakdown in the lecture.