class Solution { public: bool isPalindrome(string s) { if(s=="") return true; int i=0; string s1; while(i<s.length()){ if(s[i]>='A' && s[i]<='Z') s1+=s[i]+32; else if(s[i]>='a' && s[i]<='z') s1+=s[i]; else if(s[i]>='0' && s[i]<='9') s1+=s[i]; i++; } string s2=s1; reverse(s1.begin(),s1.end()); return s2==s1; } };
思想:利用string反转,如果跟反转之前一样,说明是回文数字