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.
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 palindrome.
给定一个字符串,判断它是不是一个字符串? 注释: 1、空字符串是回文字符串; 2、大小写不影响判断; 3、只考虑字符串中数字、字母、字符;
典型面试题,判断是否是回文字符串,只需要两个指针,一个从头开始,一个从尾开始,但是这里需要注意两点,一个是需要跳过非数字字母字符的元素,二是不区分大小写; 则这里需要将整个字符串先全部小写化,然后再当遇到非法元素时,跳过既可; PS:这里判断字符是否合法可以使用方法isalnum来实现。
