<awangdev>K Empty Slots_1.java
public int kEmptySlots(int[] flowers, int k) {
        if (flowers == null || flowers.length == 0 || k < 0) {
            return - 1;
        }

        TreeSet<Integer> treeSet = new TreeSet<>();
        for (int i = 0; i < flowers.length; i++) {
            int num = flowers[i];
            treeSet.add(num);
            Integer lower = treeSet.lower(num);
            Integer higher = treeSet.higher(num);
            if (higher != null && higher - num == k + 1 ) {
                return i + 1;
            }
            if (lower != null && num - lower == k + 1) {
                return i + 1;
            }
        }

        return -1;
    }
public int sample_funcname ( int [ ] var_0 , int var_1 ) {
  if ( var_0 == null || var_0 . length == 0 || var_1 < 0 ) {
    return - 1 ;
  }
  TreeSet < Integer > var_8 = new TreeSet < > ( ) ;
  for ( int var_9 = 0 ;
  var_9 < var_0 . length ;
  var_9 ++ ) {
    int var_10 = var_0 [ var_9 ] ;
    var_8 . add ( var_10 ) ;
    Integer lower = var_8 . lower ( var_10 ) ;
    Integer higher = var_8 . higher ( var_10 ) ;
    if ( higher != null && higher - var_10 == var_1 + 1 ) {
      return var_9 + 1 ;
    }
    if ( lower != null && var_10 - lower == var_1 + 1 ) {
      return var_9 + 1 ;
    }
  }
  return - 1 ;
}
