LeetCode16:最接近三数之和

题目

LeetCode16:最接近三数之和_第1张图片

代码

public class Solution {
    public int ThreeSumClosest(int[] nums, int target) {
        Arrays.sort(nums);
        int closestSum = 0;
        int diff = Integer.MAX_VALUE;
         
         for(int i=0; i target) 
                   right--;                
                    return temp_sum;
             }
         }        
         return closestSum;
    }
}

你可能感兴趣的:(LeetCode16:最接近三数之和)