Why the same triple appears twice.
transcript
A 3-sum that returns repeats. The totals are all right. The skips are missing. It happens only when values repeat. Equal values are common in real data.
Take five twos. The target is six. The first value is the first two. Left and right are on twos too. Every pair of twos totals four. So every group of three twos matches.
Two plus two plus two is six. A match. The code moves each pointer by one. They land on twos again. It matches again. Nothing warns you. The list only looks long.
The buggy code returns the triple twice. The right answer is one triple. A test with repeats shows it at once. Always test with equal values.
After a match, record the triple. Then move both pointers. Keep moving while the value repeats. Equal values give no new triples.
Also skip a repeated first value. Full breakdown in the lecture.