static int solve ( String s ) {
  if ( s . length ( ) <= 3 ) {
    return - 1 ;
  }
  int cnt [ ] = new int [ 25 ] ;
  for ( int i = 0 ;
  i < s . length ( ) ;
  i ++ ) {
    cnt [ s . charAt ( i ) - 'a' ] ++ ;
  }
  if ( Arrays . stream ( cnt ) . max ( ) . getAsInt ( ) >= s . length ( ) - 1 ) {
    return - 1 ;
  }
  if ( s . length ( ) % 2 == 0 ) {
    return solveEven ( s ) ;
  }
  if ( s . length ( ) % 2 == 1 ) {
    return solveOdd ( s ) ;
  }
  return Integer . MIN_VALUE ;
}

static int solve ( String s ) { if ( s . length ( ) <= 3 ) { return - 1 ; } int cnt [ ] = new int [ 25 ] ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { cnt [ s . charAt ( i ) - ' a ' ] ++ ; } if ( Arrays . stream ( cnt ) . max ( ) . getAsInt ( ) >= s . length ( ) - 1 ) { return - 1 ; } if ( s . length ( ) % 2 == 0 ) { return solveEven ( s ) ; } if ( s . length ( ) % 2 == 1 ) { return solveOdd ( s ) ; } return Integer . MIN_VALUE ; }
(method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (type_identifier) name: (identifier))) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) right: (decimal_integer_literal))) consequence: (block (return_statement (unary_expression operand: (decimal_integer_literal))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) dimensions: (dimensions) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (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: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) update: (update_expression (identifier)) body: (block (expression_statement (update_expression (array_access array: (identifier) index: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (character_literal))))))) (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (method_invocation object: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) name: (identifier) arguments: (argument_list)) name: (identifier) arguments: (argument_list)) right: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) right: (decimal_integer_literal)))) consequence: (block (return_statement (unary_expression operand: (decimal_integer_literal))))) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) right: (decimal_integer_literal)) right: (decimal_integer_literal))) consequence: (block (return_statement (method_invocation name: (identifier) arguments: (argument_list (identifier)))))) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) right: (decimal_integer_literal)) right: (decimal_integer_literal))) consequence: (block (return_statement (method_invocation name: (identifier) arguments: (argument_list (identifier)))))) (return_statement (field_access object: (identifier) field: (identifier)))))