Saturday, April 27, 2019

Palindrome


  1. Generate shortest palindrome
    1. Start check from center to both sides, the center could be one or two items.
    2. 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.
  2. 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