Skip to content

Leetcode 214: Shortest Palindrome || Comment mistake #62

@shubham4672

Description

@shubham4672

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"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions