Given an array S of n integers, 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.

Leetcode 16[medium]--3Sum Closest

思路:仍然是双支针法,先将S sort ,将元素从大到小排列。一个for 循环将三个integers中的第一个逐一定位。用另外两个指针指向后两个数。

Leetcode 16[medium]--3Sum Closest


相关文章: