Cpp solution for kids


#1

int Solution::isPalindrome(string A) {
vector v;
char b;
for(int i=0;i<A.length();i++){
b=A[i];
if(int(b)<=90&&int(b)>=65) v.push_back(int(b));
if(int(b)<=57&&int(b)>=48) v.push_back(int(b));
if(int(b)<=122&&int(b)>=97) v.push_back(int(b)-32);
}
if(v.empty()) return 1;
int i=0,j=v.size()-1;
while((j-i)>1&&v[i]==v[j]){
i++,j–;
}
if(v[i]==v[j]) return 1;
else return 0;
}