the loop calculates lps [ i ] for i = 1 to n - 1
while ( i < n ) : NEW_LINE INDENT if ( a [ i ] == b [ length ] ) : NEW_LINE INDENT length += 1 NEW_LINE lps [ i ] = length NEW_LINE i += 1 NEW_LINE DEDENT else : NEW_LINE INDENT if ( length == 0 ) : NEW_LINE INDENT lps [ i ] = 0 NEW_LINE i += 1 NEW_LINE DEDENT else : NEW_LINE INDENT length = lps [ length - 1 ] NEW_LINE DEDENT DEDENT DEDENT i = 0 NEW_LINE