static int LIS ( int [ ] a ) {
  int n = a . length ;
  int [ ] max = new int [ n + 1 ] ;
  Arrays . fill ( max , Integer . MAX_VALUE / 2 ) ;
  for ( int i = 0 ;
  i < n ;
  i ++ ) {
    int idx = Arrays . binarySearch ( max , a [ i ] ) ;
    if ( idx >= 0 ) continue ;
    idx = - ( idx + 1 ) ;
    max [ idx ] = Math . min ( a [ i ] , max [ idx ] ) ;
  }
  for ( int i = n ;
  i >= 0 ;
  i -- ) {
    if ( max [ i ] < Integer . MAX_VALUE / 2 ) return i + 1 ;
  }
  return 1 ;
}

static int LIS ( int [ ] a ) { int n = a . length ; int [ ] max = new int [ n + 1 ] ; Arrays . fill ( max , Integer . MAX_VALUE / 2 ) ; for ( int i = 0 ; i < n ; i ++ ) { int idx = Arrays . binarySearch ( max , a [ i ] ) ; if ( idx >= 0 ) continue ; idx = - ( idx + 1 ) ; max [ idx ] = Math . min ( a [ i ] , max [ idx ] ) ; } for ( int i = n ; i >= 0 ; i -- ) { if ( max [ i ] < Integer . MAX_VALUE / 2 ) return i + 1 ; } return 1 ; }
(method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (integral_type) dimensions: (dimensions)) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (field_access object: (identifier) field: (identifier)))) (local_variable_declaration type: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (binary_expression left: (identifier) right: (decimal_integer_literal)))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (binary_expression left: (field_access object: (identifier) field: (identifier)) right: (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: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (array_access array: (identifier) index: (identifier)))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (continue_statement)) (expression_statement (assignment_expression left: (identifier) right: (unary_expression operand: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal)))))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (identifier)) (array_access array: (identifier) index: (identifier)))))))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (identifier))) condition: (binary_expression left: (identifier) right: (decimal_integer_literal)) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (binary_expression left: (field_access object: (identifier) field: (identifier)) right: (decimal_integer_literal)))) consequence: (return_statement (binary_expression left: (identifier) right: (decimal_integer_literal)))))) (return_statement (decimal_integer_literal))))