You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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).