Given an array nums of n integers and an integer target, find three integers in nums such that the sum is closest to target. Return the sum of the three integers. You may assume that each input would have exactly one solution. Example: Given array nu…
三个数循环太复杂 确定一个数,搜索另两个 先排序,之后就确定了搜索的策略 if(tp>target) while (l < r && nums[r] == nums[--r]); else if (tp<target) while (l < r && nums[l] == nums[++l]); else return target;因为题目确定恰好有一组最优解,所以不用判断特殊情况一旦temp=target,直接返回 class Solution…