<gouthampradhan>two_pointers_ThreeSumClosest_1.java
public int threeSumClosest(int[] a, int target) {
    Arrays.sort(a);
    int min = Integer.MAX_VALUE, ans = -1;
    for (int i = 0, l = a.length; i < l - 2; i++) {
      if (i == 0 || !(a[i] == a[i - 1])) {
        int j = i + 1, k = l - 1;
        while (k > j) {
          if (j != i + 1 && (a[j] == a[j - 1])) {
            j++;
            continue;
          }
          int sum = a[i] + a[j] + a[k];
          if (sum < target) {
            int diff = Math.abs(sum - target);
            if (diff < min) {
              min = diff;
              ans = sum;
            }
            j++;
          } else if (sum > target) {
            int diff = Math.abs(sum - target);
            if (diff < min) {
              min = diff;
              ans = sum;
            }
            k--;
          } else {
            return sum;
          }
        }
      }
    }
    return ans;
  }
public int sample_funcname ( int [ ] var_0 , int var_1 ) {
  Arrays . sort ( var_0 ) ;
  int var_6 = Integer . MAX_VALUE , var_8 = - 1 ;
  for ( int var_10 = 0 , var_12 = var_0 . length ;
  var_10 < var_12 - 2 ;
  var_10 ++ ) {
    if ( var_10 == 0 || ! ( var_0 [ var_10 ] == var_0 [ var_10 - 1 ] ) ) {
      int var_14 = var_10 + 1 , var_15 = var_12 - 1 ;
      while ( var_15 > var_14 ) {
        if ( var_14 != var_10 + 1 && ( var_0 [ var_14 ] == var_0 [ var_14 - 1 ] ) ) {
          var_14 ++ ;
          continue ;
        }
        int var_16 = var_0 [ var_10 ] + var_0 [ var_14 ] + var_0 [ var_15 ] ;
        if ( var_16 < var_1 ) {
          int var_19 = Math . abs ( var_16 - var_1 ) ;
          if ( var_19 < var_6 ) {
            var_6 = var_19 ;
            var_8 = var_16 ;
          }
          var_14 ++ ;
        }
        else if ( var_16 > var_1 ) {
          int var_19 = Math . abs ( var_16 - var_1 ) ;
          if ( var_19 < var_6 ) {
            var_6 = var_19 ;
            var_8 = var_16 ;
          }
          var_15 -- ;
        }
        else {
          return var_16 ;
        }
      }
    }
  }
  return var_8 ;
}
