Skip to content

Commit

Permalink
cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashish-kumar7 committed Nov 25, 2020
1 parent 7a6416f commit cc5ef88
Showing 1 changed file with 46 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
class Solution {
public:
bool isPalindrome(string s) {
if(s.length()==0){
return true;
}
int i=0,j=s.length()-1;
while(i<=j){
if((s[i]>=48 and s[i]<=57) or (s[i]>=65 and s[i]<=90) or (s[i]>=97 and s[i]<=122)){
if((s[j]>=48 and s[j]<=57) or (s[j]>=65 and s[j]<=90) or (s[j]>=97 and s[j]<=122)){
if(s[i]>=48 and s[i]<=57){
if(s[i]==s[j]){
i++;
j--;
}else{
return false;
}
}
else if((s[i]>=65 and s[i]<=90) or (s[i]>=97 and s[i]<=122)){
if(s[i]==s[j] or s[i]+32==s[j] or s[i]==s[j]+32){
i++;
j--;
}
else{
return false;
}
}


}
else{
j--;
}
}else{
i++;
}
}
if(i>j){
return true;
}else{
return false;
}


}
};

0 comments on commit cc5ef88

Please sign in to comment.