public static long syakutori ( int [ ] a , int n , Set < Integer > s ) {
  int right = 0 ;
  long res = 0 ;
  long sum = 0 ;
  for ( int left = 0 ;
  left < n ;
  left ++ ) {
    while ( right < n && ! s . contains ( a [ right ] ) ) {
      s . add ( a [ right ] ) ;
      right ++ ;
    }
    res = Math . max ( res , right - left ) ;
    if ( left >= right ) {
      right ++ ;
      continue ;
    }
    s . remove ( a [ left ] ) ;
  }
  return res ;
}

public static long syakutori ( int [ ] a , int n , Set < Integer > s ) { int right = 0 ; long res = 0 ; long sum = 0 ; for ( int left = 0 ; left < n ; left ++ ) { while ( right < n && ! s . contains ( a [ right ] ) ) { s . add ( a [ right ] ) ; right ++ ; } res = Math . max ( res , right - left ) ; if ( left >= right ) { right ++ ; continue ; } s . remove ( a [ left ] ) ; } return res ; }
(method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (integral_type) dimensions: (dimensions)) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (generic_type (type_identifier) (type_arguments (type_identifier))) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (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: (identifier)) update: (update_expression (identifier)) body: (block (while_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (unary_expression operand: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (identifier))))))) body: (block (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (identifier))))) (expression_statement (update_expression (identifier))))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (binary_expression left: (identifier) right: (identifier)))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (block (expression_statement (update_expression (identifier))) (continue_statement))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (identifier))))))) (return_statement (identifier))))