static void printMax ( int arr [ ] , int n , int k ) {
  Deque < Integer > Qi = new LinkedList < Integer > ( ) ;
  int i ;
  for ( i = 0 ;
  i < k ;
  ++ i ) {
    while ( ! Qi . isEmpty ( ) && arr [ i ] >= arr [ Qi . peekLast ( ) ] ) Qi . removeLast ( ) ;
    Qi . addLast ( i ) ;
  }
  for ( ;
  i < n ;
  ++ i ) {
    System . out . print ( arr [ Qi . peek ( ) ] + " " ) ;
    while ( ( ! Qi . isEmpty ( ) ) && Qi . peek ( ) <= i - k ) Qi . removeFirst ( ) ;
    while ( ( ! Qi . isEmpty ( ) ) && arr [ i ] >= arr [ Qi . peekLast ( ) ] ) Qi . removeLast ( ) ;
    Qi . addLast ( i ) ;
  }
  System . out . print ( arr [ Qi . peek ( ) ] ) ;
}

static void printMax ( int arr [ ] , int n , int k ) { Deque < Integer > Qi = new LinkedList < Integer > ( ) ; int i ; for ( i = 0 ; i < k ; ++ i ) { while ( ! Qi . isEmpty ( ) && arr [ i ] >= arr [ Qi . peekLast ( ) ] ) Qi . removeLast ( ) ; Qi . addLast ( i ) ; } for ( ; i < n ; ++ i ) { System . out . print ( arr [ Qi . peek ( ) ] + " ▁ " ) ; while ( ( ! Qi . isEmpty ( ) ) && Qi . peek ( ) <= i - k ) Qi . removeFirst ( ) ; while ( ( ! Qi . isEmpty ( ) ) && arr [ i ] >= arr [ Qi . peekLast ( ) ] ) Qi . removeLast ( ) ; Qi . addLast ( i ) ; } System . out . print ( arr [ Qi . peek ( ) ] ) ; }
(method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier) dimensions: (dimensions)) (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (local_variable_declaration type: (generic_type (type_identifier) (type_arguments (type_identifier))) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (generic_type (type_identifier) (type_arguments (type_identifier))) arguments: (argument_list)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier))) (for_statement init: (assignment_expression left: (identifier) right: (decimal_integer_literal)) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (while_statement condition: (parenthesized_expression (binary_expression left: (unary_expression operand: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) right: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (array_access array: (identifier) index: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))))) body: (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))))) (for_statement condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (binary_expression left: (array_access array: (identifier) index: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) right: (string_literal))))) (while_statement condition: (parenthesized_expression (binary_expression left: (parenthesized_expression (unary_expression operand: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) right: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) right: (binary_expression left: (identifier) right: (identifier))))) body: (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (while_statement condition: (parenthesized_expression (binary_expression left: (parenthesized_expression (unary_expression operand: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) right: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (array_access array: (identifier) index: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))))) body: (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))))))))