leetcode valid palindrome
判断是否回文
class Solution {
public:
bool isPalindrome(string s)
{
if(s=="")return true;
for(int i=0,j=s.size()-1;i<j;)
{
while(!isalpha(s[i])&&i<j&&!isdigit(s[i]))i++;
while(!isalpha(s[j])&&i<j&&!isdigit(s[j]))j--;
if(tolower(s[i])==tolower(s[j])||s[i]==s[j])
{
i++,j--;
}
else return false;
}
return true;
}
};
浙公网安备 33010602011771号