Wednesday, January 22, 2014

Valid Palindrome (Java)


Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.
For example,
"A man, a plan, a canal: Panama" is a palindrome.
"race a car" is not a palindrome.
Have you consider that the string might be empty? This is a good question to ask during an interview.
For the purpose of this problem, we define empty string as valid palindrome.

Solution: Two Pointers 
when you see this question, you should intuitively come out an two pointers solution, however, only alphanumeric characters need be considered depend on the question's description,  so we should use relative elegant way to check the validity of each character.