static int findMaxXOR ( Vector < Integer > arr , int n ) {
  Vector < Integer > stack = new Vector < Integer > ( ) ;
  int res = 0 , l = 0 , i ;
  for ( i = 0 ;
  i < n ;
  i ++ ) {
    while ( ! stack . isEmpty ( ) && stack . get ( stack . size ( ) - 1 ) < arr . get ( i ) ) {
      stack . remove ( stack . size ( ) - 1 ) ;
      l -- ;
    }
    stack . add ( arr . get ( i ) ) ;
    l ++ ;
    if ( l > 1 ) {
      res = Math . max ( res , stack . get ( l - 1 ) ^ stack . get ( l - 2 ) ) ;
    }
  }
  return res ;
}

static int findMaxXOR ( Vector < Integer > arr , int n ) { Vector < Integer > stack = new Vector < Integer > ( ) ; int res = 0 , l = 0 , i ; for ( i = 0 ; i < n ; i ++ ) { while ( ! stack . isEmpty ( ) && stack . get ( stack . size ( ) - 1 ) < arr . get ( i ) ) { stack . remove ( stack . size ( ) - 1 ) ; l -- ; } stack . add ( arr . get ( i ) ) ; l ++ ; if ( l > 1 ) { res = Math . max ( res , stack . get ( l - 1 ) ^ stack . get ( l - 2 ) ) ; } } return res ; }
(method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (generic_type (type_identifier) (type_arguments (type_identifier))) 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) value: (decimal_integer_literal)) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal)) 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: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) right: (decimal_integer_literal)))) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))))) body: (block (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) right: (decimal_integer_literal))))) (expression_statement (update_expression (identifier))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))))) (expression_statement (update_expression (identifier))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (decimal_integer_literal)))) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (decimal_integer_literal))))))))))))) (return_statement (identifier))))