static int LongIncrConseqSubseq ( int arr [ ] , int n ) {
  HashMap < Integer , Integer > map = new HashMap < > ( ) ;
  map . put ( arr [ 0 ] , 1 ) ;
  for ( int i = 1 ;
  i < n ;
  i ++ ) {
    if ( map . containsKey ( arr [ i ] - 1 ) ) {
      map . put ( arr [ i ] , map . get ( arr [ i ] - 1 ) + 1 ) ;
      map . remove ( arr [ i ] - 1 ) ;
    }
    else {
      map . put ( arr [ i ] , 1 ) ;
    }
  }
  return Collections . max ( map . values ( ) ) ;
}

static int LongIncrConseqSubseq ( int arr [ ] , int n ) { HashMap < Integer , Integer > map = new HashMap < > ( ) ; map . put ( arr [ 0 ] , 1 ) ; for ( int i = 1 ; i < n ; i ++ ) { if ( map . containsKey ( arr [ i ] - 1 ) ) { map . put ( arr [ i ] , map . get ( arr [ i ] - 1 ) + 1 ) ; map . remove ( arr [ i ] - 1 ) ; } else { map . put ( arr [ i ] , 1 ) ; } } return Collections . max ( map . values ( ) ) ; }
(method_declaration (modifiers) type: (integral_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) (type_identifier))) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (generic_type (type_identifier) (type_arguments)) arguments: (argument_list)))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (decimal_integer_literal)) (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 (if_statement condition: (parenthesized_expression (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal))))) consequence: (block (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (identifier)) (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal)))) right: (decimal_integer_literal))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal)))))) alternative: (block (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (identifier)) (decimal_integer_literal)))))))) (return_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))))))