public static int threeSumClosest(int[] num, int target) {
        Arrays.sort(num);
        int diff = Integer.MAX_VALUE, result = Integer.MAX_VALUE;
        for(int i = 0; i < num.length; i++){
            int start = i + 1, end = num.length - 1;
            while(start < end){
                if(Math.abs(num[start] + num[end] + num[i] - target) < diff){
                    diff = Math.abs(num[start] + num[end] + num[i] - target);
                    result = num[start] + num[end] + num[i];
                }
                if(num[start] + num[end] + num[i] < target){
                    start++;
                }else if(num[start] + num[end] + num[i] > target){
                    end--;
                }else{
                    return result;
                }
            }
        }
        return result;
    }