16 3Sum Closest
16. 3Sum Closest
1. Question
Given an arraySofnintegers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would have exactly one solution.
2. Implementation
(1) Two Pointers
3. Time & Space Complexity
Two Pointers: 时间复杂度O(n^2), 空间复杂度O(logn),sorting需要logn的空间
Last updated