static boolean possibleSameCharFreqByOneRemoval ( String str ) {
  int l = str . length ( ) ;
  int [ ] freq = new int [ M ] ;
  for ( int i = 0 ;
  i < l ;
  i ++ ) freq [ getIdx ( str . charAt ( i ) ) ] ++ ;
  if ( allSame ( freq , M ) ) return true ;
  for ( char c = 'a' ;
  c <= 'z' ;
  c ++ ) {
    int i = getIdx ( c ) ;
    if ( freq [ i ] > 0 ) {
      freq [ i ] -- ;
      if ( allSame ( freq , M ) ) return true ;
      freq [ i ] ++ ;
    }
  }
  return false ;
}

static boolean possibleSameCharFreqByOneRemoval ( String str ) { int l = str . length ( ) ; int [ ] freq = new int [ M ] ; for ( int i = 0 ; i < l ; i ++ ) freq [ getIdx ( str . charAt ( i ) ) ] ++ ; if ( allSame ( freq , M ) ) return true ; for ( char c = ' a ' ; c <= ' z ' ; c ++ ) { int i = getIdx ( c ) ; if ( freq [ i ] > 0 ) { freq [ i ] -- ; if ( allSame ( freq , M ) ) return true ; freq [ i ] ++ ; } } return false ; }
(method_declaration (modifiers) type: (boolean_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (type_identifier) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (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))))) (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: (expression_statement (update_expression (array_access array: (identifier) index: (method_invocation name: (identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))))))) (if_statement condition: (parenthesized_expression (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier)))) consequence: (return_statement (true))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (character_literal))) condition: (binary_expression left: (identifier) right: (character_literal)) update: (update_expression (identifier)) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation name: (identifier) arguments: (argument_list (identifier))))) (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal))) consequence: (block (expression_statement (update_expression (array_access array: (identifier) index: (identifier)))) (if_statement condition: (parenthesized_expression (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier)))) consequence: (return_statement (true))) (expression_statement (update_expression (array_access array: (identifier) index: (identifier)))))))) (return_statement (false))))