static String LPS ( String pat , int [ ] lps ) {
  int M = pat . length ( ) , len = 0 , i = 1 ;
  lps [ 0 ] = 0 ;
  while ( i < M ) if ( pat . charAt ( i ) == pat . charAt ( len ) ) lps [ i ++ ] = ++ len ;
  else if ( len != 0 ) len = lps [ len - 1 ] ;
  else lps [ i ++ ] = 0 ;
  return pat . substring ( 0 , lps [ M - 1 ] ) ;
}

static String LPS ( String pat , int [ ] lps ) { int M = pat . length ( ) , len = 0 , i = 1 ; lps [ 0 ] = 0 ; while ( i < M ) if ( pat . charAt ( i ) == pat . charAt ( len ) ) lps [ i ++ ] = ++ len ; else if ( len != 0 ) len = lps [ len - 1 ] ; else lps [ i ++ ] = 0 ; return pat . substring ( 0 , lps [ M - 1 ] ) ; }
(method_declaration (modifiers) type: (type_identifier) name: (identifier) parameters: (formal_parameters (formal_parameter type: (type_identifier) name: (identifier)) (formal_parameter type: (array_type element: (integral_type) dimensions: (dimensions)) 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))) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal)) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (decimal_integer_literal)) right: (decimal_integer_literal))) (while_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) body: (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: (expression_statement (assignment_expression left: (array_access array: (identifier) index: (update_expression (identifier))) right: (update_expression (identifier)))) alternative: (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (expression_statement (assignment_expression left: (identifier) right: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))))) alternative: (expression_statement (assignment_expression left: (array_access array: (identifier) index: (update_expression (identifier))) right: (decimal_integer_literal)))))) (return_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal) (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))))))))