Interview_DS_Algo icon indicating copy to clipboard operation
Interview_DS_Algo copied to clipboard

Leetcode 214: Shortest Palindrome || Comment mistake

Open shubham4672 opened this issue 1 year ago • 0 comments

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"

shubham4672 avatar Jan 11 '25 07:01 shubham4672