static void minSteps ( int arr [ ] , int N ) {
  Stack < Node > s = new Stack < Node > ( ) ;
  s . add ( new Node ( 0 , - 1 ) ) ;
  int maxStepsToeliminate = - 1 ;
  for ( int i = 1 ;
  i < N ;
  i ++ ) {
    int stepsToeliminate = 1 ;
    while ( ! s . isEmpty ( ) ) {
      if ( arr [ s . peek ( ) . elementID ] >= arr [ i ] ) {
        stepsToeliminate = Math . max ( stepsToeliminate , s . peek ( ) . stepsToeliminate + 1 ) ;
        s . pop ( ) ;
      }
      else {
        break ;
      }
    }
    if ( s . isEmpty ( ) ) {
      stepsToeliminate = - 1 ;
    }
    maxStepsToeliminate = Math . max ( maxStepsToeliminate , stepsToeliminate ) ;
    s . add ( new Node ( i , stepsToeliminate ) ) ;
  }
  System . out . print ( ( maxStepsToeliminate < 0 ? 0 : maxStepsToeliminate ) + "\n" ) ;
}

static void minSteps ( int arr [ ] , int N ) { Stack < Node > s = new Stack < Node > ( ) ; s . add ( new Node ( 0 , - 1 ) ) ; int maxStepsToeliminate = - 1 ; for ( int i = 1 ; i < N ; i ++ ) { int stepsToeliminate = 1 ; while ( ! s . isEmpty ( ) ) { if ( arr [ s . peek ( ) . elementID ] >= arr [ i ] ) { stepsToeliminate = Math . max ( stepsToeliminate , s . peek ( ) . stepsToeliminate + 1 ) ; s . pop ( ) ; } else { break ; } } if ( s . isEmpty ( ) ) { stepsToeliminate = - 1 ; } maxStepsToeliminate = Math . max ( maxStepsToeliminate , stepsToeliminate ) ; s . add ( new Node ( i , stepsToeliminate ) ) ; } System . out . print ( ( maxStepsToeliminate < 0 ? 0 : maxStepsToeliminate ) + " \n " ) ; }
(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))) 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)))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (object_creation_expression type: (type_identifier) arguments: (argument_list (decimal_integer_literal) (unary_expression operand: (decimal_integer_literal))))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (unary_expression operand: (decimal_integer_literal)))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (while_statement condition: (parenthesized_expression (unary_expression operand: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (field_access object: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) field: (identifier))) right: (array_access array: (identifier) index: (identifier)))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (binary_expression left: (field_access object: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) field: (identifier)) right: (decimal_integer_literal)))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) alternative: (block (break_statement))))) (if_statement condition: (parenthesized_expression (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (unary_expression operand: (decimal_integer_literal)))))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (identifier))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (object_creation_expression type: (type_identifier) arguments: (argument_list (identifier) (identifier)))))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (binary_expression left: (parenthesized_expression (ternary_expression condition: (binary_expression left: (identifier) right: (decimal_integer_literal)) consequence: (decimal_integer_literal) alternative: (identifier))) right: (string_literal)))))))