Problem. Return all unique triples [a, b, c] from nums (three different positions) with
a + b + c == 0. The answer must not contain the same triple twice.
[-1, 0, 1, 2, -1, -4] → [[-1, -1, 2], [-1, 0, 1]]
[0, 1, 1] → []
[0, 0, 0, 0] → [[0, 0, 0]]
ML context. "Pick three items whose costs hit a budget exactly, and list each combination once" is the same search: three model calls whose latencies sum to an SLO, three shards whose sizes fill a node. The two lessons that carry over are reduce k-Sum to (k − 1) loops plus two pointers, and de-duplicate by skipping equal neighbours in sorted data instead of hashing the results.