1. Problem Given a string, determine if it is a palindrome , considering only alphanumeric characters and ignoring cases. Note that empty string is regarded as a palindrome. For example, "A man, a plan, a canal: Panama" is a palindrome, while "race a car" is not a palindrome. 2. Idea Going from the two ends of the string to the center, compare the alphanumeric characters met and see if they match. Once a mismatch occurs, the string must not be a palindrome. When all characters are visited and no mismatch occurs, it is a palindrome. 3.
Read full article from LeetCode - Valid Palindrome | Darren's Blog
No comments:
Post a Comment