Two Sum - Closest to target
ID: 533; medium
Solution 1 (Java)
Notes
We sort the array first using the built-in method.
Then, we update the minimum difference when possible and we use the opposite two pointers to keep track of the difference.
Make sure to add absolute value for
diff
as required by the problem.
Last updated