Interview_DS_Algo
Interview_DS_Algo copied to clipboard
Leetcode 214: Shortest Palindrome || Comment mistake
Comment should be deleted
There is a small issue in the code for finding LPS it is mentioned in the comment: Shortest Palindrome.cpp
Line No. 52 and 123:
len = lps[len - 1]; // You can also write, len = len-1;
You can't just reduce the len by one; you can only replace it with the previous element of the lps array, when len > 0 and pat.charAt(i) != pat.charAt(len).
For this test case, the problem arises:
input: "ababbbabbaba"
output: "ababbababbbabbaba"
expected: "ababbabbbababbbabbaba"