static int longestPrefixSuffix ( String s ) {
  int n = s . length ( ) ;
  if ( n < 2 ) {
    return 0 ;
  }
  int len = 0 ;
  int i = n / 2 ;
  while ( i < n ) {
    if ( s . charAt ( i ) == s . charAt ( len ) ) {
      ++ len ;
      ++ i ;
    }
    else {
      if ( len == 0 ) {
        ++ i ;
      }
      else {
        -- len ;
      }
    }
  }
  return len ;
}

static int longestPrefixSuffix ( String s ) { int n = s . length ( ) ; if ( n < 2 ) { return 0 ; } int len = 0 ; int i = n / 2 ; while ( i < n ) { if ( s . charAt ( i ) == s . charAt ( len ) ) { ++ len ; ++ i ; } else { if ( len == 0 ) { ++ i ; } else { -- len ; } } } return len ; }
(method_declaration (modifiers) type: (integral_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)))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (block (return_statement (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: (binary_expression left: (identifier) right: (decimal_integer_literal)))) (while_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))) consequence: (block (expression_statement (update_expression (identifier))) (expression_statement (update_expression (identifier)))) alternative: (block (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (block (expression_statement (update_expression (identifier)))) alternative: (block (expression_statement (update_expression (identifier))))))))) (return_statement (identifier))))