- Generate shortest palindrome
- Start check from center to both sides, the center could be one or two items.
- In each check method, if it could expand to one end, the palindrome is found. We just need to reverse the rest of string and add to the other side.
- Check if it's a palindrome
- User two pointer scan from both sides to center, until two pointers meet
- Or start from center to both side, we need to check the number of characters is old or even
No comments:
Post a Comment