public static int threeSumClosest(int[] numbers, int target) {
        // write your code here
        
        if (numbers == null || numbers.length < 3){
            return 0;
        }
        
        Arrays.sort(numbers);
        int closest = Integer.MAX_VALUE / 2;;
        
        for (int i = 0; i < numbers.length; i++){
            int left = i + 1;
            int right = numbers.length - 1;
            
            while (left < right){
                int sum = numbers[i] + numbers[left] + numbers[right];
                if (sum == target){
                	return sum;
                } else if (sum < target){
                	left++;
                } else {
                	right--;
                }
                if (Math.abs(target - sum) < Math.abs(target - closest)){
                    closest = sum;
                } 
            }
            
        }
        return closest;
    }