方法一:筛选+逆向判断
class Solution
{
public:
bool isPalindrome(string s)
{
string tmp;
for (auto& x : s)
{
if (isalnum(x))
{
tmp += tolower(x);
}
}
string tmp_tmp(tmp.rbegin(), tmp.rend());
return tmp_tmp == tmp;
}
};
int main()
{
Solution A;
cout