class Solution { public: //check whther this character is alphanumeric character //also if the parameter is upper capital, we just change it to lower capital. bool isalnu(char &c){ if(c >= 'a' && c <= 'z') return true; else if(c >= 'A' && c <= 'Z'){ c = c- 'A' + 'a'; return true; } else if(c >= '0' && c <= '9') return true; else return false; } bool isPalindrome(string s) { int start = 0, end = s.size() - 1, len = s.size(); while(start < end){ if(!isalnu(s[start])){//continue until a valid character start++; continue; } while(!isalnu(s[end])){//continue until a valid character end--; continue; } //if the character is different if(s[start] != s[end]) return false; start++; end--; } return true; } };