<gouthampradhan>heap_SlidingWindowMaximum_1.java
public int[] maxSlidingWindow(int[] nums, int k) {
    int[] result = new int[nums.length - (k - 1)];
    if (nums.length == 0) return new int[0];
    Deque<Integer> queue = new ArrayDeque<>();
    for (int i = 0, j = 0, l = nums.length; i < l; i++) {
      int head = i - (k - 1);
      if (head >= 0) {
        if (queue.peek() != null && queue.peek() < head) queue.poll();
      }
      while (queue.peekLast() != null && nums[queue.peekLast()] <= nums[i]) {
        queue.pollLast();
      }
      queue.offer(i);
      if (i >= k - 1) result[j++] = nums[queue.peek()];
    }
    return result;
  }
public int [ ] sample_funcname ( int [ ] var_0 , int var_1 ) {
  int [ ] var_4 = new int [ var_0 . length - ( var_1 - 1 ) ] ;
  if ( var_0 . length == 0 ) return new int [ 0 ] ;
  Deque < Integer > var_9 = new ArrayDeque < > ( ) ;
  for ( int var_10 = 0 , var_11 = 0 , var_12 = var_0 . length ;
  var_10 < var_12 ;
  var_10 ++ ) {
    int var_13 = var_10 - ( var_1 - 1 ) ;
    if ( var_13 >= 0 ) {
      if ( var_9 . peek ( ) != null && var_9 . peek ( ) < var_13 ) var_9 . poll ( ) ;
    }
    while ( var_9 . peekLast ( ) != null && var_0 [ var_9 . peekLast ( ) ] <= var_0 [ var_10 ] ) {
      var_9 . pollLast ( ) ;
    }
    var_9 . offer ( var_10 ) ;
    if ( var_10 >= var_1 - 1 ) var_4 [ var_11 ++ ] = var_0 [ var_9 . peek ( ) ] ;
  }
  return var_4 ;
}
