public static int [ ] computeLPSArray ( String str ) {
  int n = str . length ( ) ;
  int lps [ ] = new int [ n ] ;
  int i = 1 , len = 0 ;
  lps [ 0 ] = 0 ;
  while ( i < n ) {
    if ( str . charAt ( i ) == str . charAt ( len ) ) {
      len ++ ;
      lps [ i ] = len ;
      i ++ ;
    }
    else {
      if ( len != 0 ) {
        len = lps [ len - 1 ] ;
      }
      else {
        lps [ i ] = 0 ;
        i ++ ;
      }
    }
  }
  return lps ;
}

public static int [ ] computeLPSArray ( String str ) { int n = str . length ( ) ; int lps [ ] = new int [ n ] ; int i = 1 , len = 0 ; lps [ 0 ] = 0 ; while ( i < n ) { if ( str . charAt ( i ) == str . charAt ( len ) ) { len ++ ; lps [ i ] = len ; i ++ ; } else { if ( len != 0 ) { len = lps [ len - 1 ] ; } else { lps [ i ] = 0 ; i ++ ; } } } return lps ; }
(method_declaration (modifiers) type: (array_type element: (integral_type) dimensions: (dimensions)) 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)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) dimensions: (dimensions) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (identifier))))) (local_variable_declaration type: (integral_type) 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: (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 (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (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 (assignment_expression left: (identifier) right: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal)))))) alternative: (block (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal))) (expression_statement (update_expression (identifier))))))))) (return_statement (identifier))))