Q125. Valid Palindrome
Last updated
Was this helpful?
Last updated
Was this helpful?
直达:
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"
isnota palindrome.
Note: 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 palindrom
首先将字符串清洗一下,包括两个步骤:
保留字母和数字
将大写字母转小写
然后使用头尾两个指针判断字符串是否是回文。