Given an integer array and a target, find the sum of three integers closest to the target. Sorting reduces the search to a fixed element plus a two-pointer sweep for the remaining two values.
nums = array of integers, target = target sum
closest three-number sum
Example 1:
Input:
nums = [-1,2,1,-4] target = 1
Output:
2
Explanation:
The sum 2 is the closest to target 1.
Example 2:
Input:
nums = [0,0,0] target = 1
Output:
0
Explanation:
Only sum possible is 0.