Closest Pair Sum — Solution & Editorial
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)
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)