<gouthampradhan>array_KEmptySlots_1.java
public int kEmptySlots(int[] flowers, int k) {
    TreeSet<Integer> set = new TreeSet<>();
    for (int i = 0; i < flowers.length; i++) {
      Integer lowerBound = set.floor(flowers[i]);
      Integer upperBound = set.ceiling(flowers[i]);
      if (lowerBound != null) {
        if ((Math.abs(flowers[i] - lowerBound) + 1) == k) {
          return i + 1;
        }
      }
      if (upperBound != null) {
        if ((Math.abs(flowers[i] - upperBound) + 1) == k) {
          return i + 1;
        }
      }
      set.add(flowers[i]);
    }
    return -1;
  }
public int sample_funcname ( int [ ] var_0 , int var_1 ) {
  TreeSet < Integer > var_4 = new TreeSet < > ( ) ;
  for ( int var_6 = 0 ;
  var_6 < var_0 . length ;
  var_6 ++ ) {
    Integer var_9 = var_4 . floor ( var_0 [ var_6 ] ) ;
    Integer var_11 = var_4 . ceiling ( var_0 [ var_6 ] ) ;
    if ( var_9 != null ) {
      if ( ( Math . abs ( var_0 [ var_6 ] - var_9 ) + 1 ) == var_1 ) {
        return var_6 + 1 ;
      }
    }
    if ( var_11 != null ) {
      if ( ( Math . abs ( var_0 [ var_6 ] - var_11 ) + 1 ) == var_1 ) {
        return var_6 + 1 ;
      }
    }
    var_4 . add ( var_0 [ var_6 ] ) ;
  }
  return - 1 ;
}
