static int uniqueNumbers ( int arr [ ] , int n ) {
  Arrays . sort ( arr ) ;
  int freq [ ] = new int [ n + 2 ] ;
  for ( int i = 0 ;
  i < n + 2 ;
  i ++ ) freq [ i ] = 0 ;
  for ( int x = 0 ;
  x < n ;
  x ++ ) {
    if ( freq [ arr [ x ] - 1 ] == 0 ) {
      freq [ arr [ x ] - 1 ] ++ ;
    }
    else if ( freq [ arr [ x ] ] == 0 ) {
      freq [ arr [ x ] ] ++ ;
    }
    else {
      freq [ arr [ x ] + 1 ] ++ ;
    }
  }
  int unique = 0 ;
  for ( int x = 0 ;
  x <= n + 1 ;
  x ++ ) {
    if ( freq [ x ] != 0 ) {
      unique ++ ;
    }
  }
  return unique ;
}

static int uniqueNumbers ( int arr [ ] , int n ) { Arrays . sort ( arr ) ; int freq [ ] = new int [ n + 2 ] ; for ( int i = 0 ; i < n + 2 ; i ++ ) freq [ i ] = 0 ; for ( int x = 0 ; x < n ; x ++ ) { if ( freq [ arr [ x ] - 1 ] == 0 ) { freq [ arr [ x ] - 1 ] ++ ; } else if ( freq [ arr [ x ] ] == 0 ) { freq [ arr [ x ] ] ++ ; } else { freq [ arr [ x ] + 1 ] ++ ; } } int unique = 0 ; for ( int x = 0 ; x <= n + 1 ; x ++ ) { if ( freq [ x ] != 0 ) { unique ++ ; } } return unique ; }
(method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier) dimensions: (dimensions)) (formal_parameter type: (integral_type) name: (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) dimensions: (dimensions) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (binary_expression left: (identifier) right: (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: (binary_expression left: (identifier) right: (decimal_integer_literal))) update: (update_expression (identifier)) body: (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (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: (identifier)) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal))) right: (decimal_integer_literal))) consequence: (block (expression_statement (update_expression (array_access array: (identifier) index: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal)))))) alternative: (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (array_access array: (identifier) index: (identifier))) right: (decimal_integer_literal))) consequence: (block (expression_statement (update_expression (array_access array: (identifier) index: (array_access array: (identifier) index: (identifier)))))) alternative: (block (expression_statement (update_expression (array_access array: (identifier) index: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal)))))))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (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: (binary_expression left: (identifier) right: (decimal_integer_literal))) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal))) consequence: (block (expression_statement (update_expression (identifier))))))) (return_statement (identifier))))