static String getMaxEven ( char [ ] str , int len ) {
  int [ ] freq = new int [ MAX ] ;
  int i , minEvenDigit = MAX , minDigit = MAX ;
  for ( i = 0 ;
  i < len ;
  i ++ ) {
    int digit = str [ i ] - '0' ;
    freq [ digit ] ++ ;
    if ( digit % 2 == 0 ) minEvenDigit = Math . min ( digit , minEvenDigit ) ;
    minDigit = Math . min ( digit , minDigit ) ;
  }
  if ( minEvenDigit == MAX ) return "-1" ;
  freq [ minEvenDigit ] -- ;
  freq [ minDigit ] -- ;
  i = 0 ;
  for ( int j = MAX - 1 ;
  j >= 0 ;
  j -- ) {
    for ( int k = 0 ;
    k < freq [ j ] ;
    k ++ ) str [ i ++ ] = ( char ) ( j + '0' ) ;
    if ( j == minEvenDigit ) str [ i ++ ] = ( char ) ( minDigit + '0' ) ;
  }
  str [ i - 1 ] = ( char ) ( minEvenDigit + '0' ) ;
  return String . valueOf ( str ) ;
}

static String getMaxEven ( char [ ] str , int len ) { int [ ] freq = new int [ MAX ] ; int i , minEvenDigit = MAX , minDigit = MAX ; for ( i = 0 ; i < len ; i ++ ) { int digit = str [ i ] - '0' ; freq [ digit ] ++ ; if ( digit % 2 == 0 ) minEvenDigit = Math . min ( digit , minEvenDigit ) ; minDigit = Math . min ( digit , minDigit ) ; } if ( minEvenDigit == MAX ) return " - 1" ; freq [ minEvenDigit ] -- ; freq [ minDigit ] -- ; i = 0 ; for ( int j = MAX - 1 ; j >= 0 ; j -- ) { for ( int k = 0 ; k < freq [ j ] ; k ++ ) str [ i ++ ] = ( char ) ( j + '0' ) ; if ( j == minEvenDigit ) str [ i ++ ] = ( char ) ( minDigit + '0' ) ; } str [ i - 1 ] = ( char ) ( minEvenDigit + '0' ) ; return String . valueOf ( str ) ; }
(method_declaration (modifiers) type: (type_identifier) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (integral_type) dimensions: (dimensions)) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (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 (identifier))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier)) declarator: (variable_declarator name: (identifier) value: (identifier)) declarator: (variable_declarator name: (identifier) value: (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 (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (character_literal)))) (expression_statement (update_expression (array_access array: (identifier) index: (identifier)))) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (decimal_integer_literal))) consequence: (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (identifier)))))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (identifier))))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (return_statement (string_literal))) (expression_statement (update_expression (array_access array: (identifier) index: (identifier)))) (expression_statement (update_expression (array_access array: (identifier) index: (identifier)))) (expression_statement (assignment_expression left: (identifier) right: (decimal_integer_literal))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (decimal_integer_literal)))) condition: (binary_expression left: (identifier) right: (decimal_integer_literal)) update: (update_expression (identifier)) body: (block (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (array_access array: (identifier) index: (identifier))) update: (update_expression (identifier)) body: (expression_statement (assignment_expression left: (array_access array: (identifier) index: (update_expression (identifier))) right: (cast_expression type: (integral_type) value: (parenthesized_expression (binary_expression left: (identifier) right: (character_literal))))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (expression_statement (assignment_expression left: (array_access array: (identifier) index: (update_expression (identifier))) right: (cast_expression type: (integral_type) value: (parenthesized_expression (binary_expression left: (identifier) right: (character_literal))))))))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (cast_expression type: (integral_type) value: (parenthesized_expression (binary_expression left: (identifier) right: (character_literal)))))) (return_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))))