public int threeSumClosest(int[] num, int target) {
			int closest = 0;
			if (num.length <= 2)
				return closest;

			Arrays.sort(num);
			int gap = Integer.MAX_VALUE;
			for (int i = 0; i <= num.length - 3; i++) {
				int first = i + 1;
				int last = num.length - 1;

				while (first < last) {
					int sum = num[i] + num[first] + num[last];

					if (sum == target)
						return target;

					if (Math.abs(sum - target) < gap) {
						closest = sum;
						gap = Math.abs(sum - target);
					}

					if (sum > target) {
						last--;
					} else {
						first++;
					}

				}
			}
			return closest;
		}