private static String dfs ( HashSet < Integer > dis , int idx , int [ ] num , int low ) {
  if ( idx == num . length ) return "" ;
  int i = num [ idx ] ;
  while ( dis . contains ( i ) ) i ++ ;
  if ( i > 9 ) return null ;
  if ( i == num [ idx ] ) {
    String next = dfs ( dis , idx + 1 , num , low ) ;
    if ( next != null ) return "" + i + next ;
    i ++ ;
    while ( dis . contains ( i ) ) i ++ ;
    if ( i > 9 ) return null ;
  }
  StringBuilder sb = new StringBuilder ( ) ;
  sb . append ( i ) ;
  for ( int j = 0 ;
  j < num . length - idx - 1 ;
  j ++ ) sb . append ( low ) ;
  return sb . toString ( ) ;
}

private static String dfs ( HashSet < Integer > dis , int idx , int [ ] num , int low ) { if ( idx == num . length ) return " " ; int i = num [ idx ] ; while ( dis . contains ( i ) ) i ++ ; if ( i > 9 ) return null ; if ( i == num [ idx ] ) { String next = dfs ( dis , idx + 1 , num , low ) ; if ( next != null ) return " " + i + next ; i ++ ; while ( dis . contains ( i ) ) i ++ ; if ( i > 9 ) return null ; } StringBuilder sb = new StringBuilder ( ) ; sb . append ( i ) ; for ( int j = 0 ; j < num . length - idx - 1 ; j ++ ) sb . append ( low ) ; return sb . toString ( ) ; }
(method_declaration (modifiers) type: (type_identifier) name: (identifier) parameters: (formal_parameters (formal_parameter type: (generic_type (type_identifier) (type_arguments (type_identifier))) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (array_type element: (integral_type) dimensions: (dimensions)) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (field_access object: (identifier) field: (identifier)))) consequence: (return_statement (string_literal))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (array_access array: (identifier) index: (identifier)))) (while_statement condition: (parenthesized_expression (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))) body: (expression_statement (update_expression (identifier)))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (return_statement (null_literal))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (array_access array: (identifier) index: (identifier)))) consequence: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (method_invocation name: (identifier) arguments: (argument_list (identifier) (binary_expression left: (identifier) right: (decimal_integer_literal)) (identifier) (identifier))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (null_literal))) consequence: (return_statement (binary_expression left: (binary_expression left: (string_literal) right: (identifier)) right: (identifier)))) (expression_statement (update_expression (identifier))) (while_statement condition: (parenthesized_expression (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))) body: (expression_statement (update_expression (identifier)))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (return_statement (null_literal))))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list)))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (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: (binary_expression left: (binary_expression left: (field_access object: (identifier) field: (identifier)) right: (identifier)) right: (decimal_integer_literal))) update: (update_expression (identifier)) body: (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))) (return_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))))