<awangdev>K Empty Slots_2.java
public int kEmptySlots(int[] flowers, int k) {
        if (flowers == null || flowers.length == 0 || k < 0) {
            return - 1;
        }
        int n = flowers.length;
        int[] days = new int[n];
        for (int i = 0; i < n; i++) {
            days[flowers[i] - 1] = i + 1; 
        }

        int left = 0, right = k + 1, result = Integer.MAX_VALUE;
        for (int i = 0; right < n; i++) {
            if (days[i] < days[left] || days[i] <= days[right]) {
                if (i == right) {
                    result = Math.min(result, Math.max(days[left], days[right]));
                }
                left = i;
                right = k + 1 + i;
            }
        }
        return result == Integer.MAX_VALUE ? - 1 : result;
    }
public int sample_funcname ( int [ ] var_0 , int var_1 ) {
  if ( var_0 == null || var_0 . length == 0 || var_1 < 0 ) {
    return - 1 ;
  }
  int var_6 = var_0 . length ;
  int [ ] var_7 = new int [ var_6 ] ;
  for ( int var_8 = 0 ;
  var_8 < var_6 ;
  var_8 ++ ) {
    var_7 [ var_0 [ var_8 ] - 1 ] = var_8 + 1 ;
  }
  int var_9 = 0 , var_10 = var_1 + 1 , var_13 = Integer . MAX_VALUE ;
  for ( int var_8 = 0 ;
  var_10 < var_6 ;
  var_8 ++ ) {
    if ( var_7 [ var_8 ] < var_7 [ var_9 ] || var_7 [ var_8 ] <= var_7 [ var_10 ] ) {
      if ( var_8 == var_10 ) {
        var_13 = Math . min ( var_13 , Math . max ( var_7 [ var_9 ] , var_7 [ var_10 ] ) ) ;
      }
      var_9 = var_8 ;
      var_10 = var_1 + 1 + var_8 ;
    }
  }
  return var_13 == Integer . MAX_VALUE ? - 1 : var_13 ;
}
