Problem 16 · Medium

3Sum Closest

Locate the three-value combination whose sum is nearest a target by sorting and moving two pointers inward. The visual tracks the best gap so far as the pointers converge.

Open the interactive visualisation