public static boolean isNumBalanced ( int num ) {
  num = Math . abs ( num ) ;
  String str = num + "" ;
  char [ ] ch_arr = str . toCharArray ( ) ;
  HashSet < Character > hs = new HashSet < Character > ( ) ;
  for ( char ch : ch_arr ) {
    hs . add ( ch ) ;
  }
  int str_len = str . length ( ) ;
  int hs_len = hs . size ( ) ;
  if ( hs_len <= str_len / 2 || hs_len == str_len ) {
    return true ;
  }
  return false ;
}

public static boolean isNumBalanced ( int num ) { num = Math . abs ( num ) ; String str = num + " " ; char [ ] ch_arr = str . toCharArray ( ) ; HashSet < Character > hs = new HashSet < Character > ( ) ; for ( char ch : ch_arr ) { hs . add ( ch ) ; } int str_len = str . length ( ) ; int hs_len = hs . size ( ) ; if ( hs_len <= str_len / 2 || hs_len == str_len ) { return true ; } return false ; }
(method_declaration (modifiers) type: (boolean_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier))) body: (block (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (string_literal)))) (local_variable_declaration type: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (generic_type (type_identifier) (type_arguments (type_identifier))) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (generic_type (type_identifier) (type_arguments (type_identifier))) arguments: (argument_list)))) (enhanced_for_statement type: (integral_type) name: (identifier) value: (identifier) body: (block (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))))) (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: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (binary_expression left: (identifier) right: (identifier)))) consequence: (block (return_statement (true)))) (return_statement (false))))