classSolution { public: intthreeSumClosest(vector<int>& nums, int target){
int len = nums.size(); sort(nums.begin(), nums.end());
int L, R; int res = nums[0] + nums[1] + nums[2]; for(int i = 0; i < len; ++i) { L = i + 1; R = len - 1; while(L < R) { int sum = nums[i] + nums[L] + nums[R]; if(sum == target) return target;
if(abs(sum - target) < abs(res - target)) res = sum;