classSolution{public:boolisPalindrome(string s){int i =0, j = s.length()-1;while(i < j &&!isalnum(s[i])){++i;}while(i < j &&!isalnum(s[j])){--j;}int n = j - i +1;if(n ==0|| n ==1){returntrue;}char left =tolower(s[i]), right =tolower(s[j]);if(n ==2){return left == right;}if(left == right){returnisPalindrome(s.substr(i +1, n -2));}returnfalse;}};