Problems > Closest Pair Sum > Editorial

Closest Pair Sum — Solution & Editorial

Back to the Problem

Sort and walk two pointers inward: move the left pointer up when the sum is too small, the right pointer down when too large, tracking the best sum seen.

Complexity: O(N log N)