Skip to content

Commit cc5ef88

Browse files
committed
cpp
1 parent 7a6416f commit cc5ef88

1 file changed

+46
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
class Solution {
2+
public:
3+
bool isPalindrome(string s) {
4+
if(s.length()==0){
5+
return true;
6+
}
7+
int i=0,j=s.length()-1;
8+
while(i<=j){
9+
if((s[i]>=48 and s[i]<=57) or (s[i]>=65 and s[i]<=90) or (s[i]>=97 and s[i]<=122)){
10+
if((s[j]>=48 and s[j]<=57) or (s[j]>=65 and s[j]<=90) or (s[j]>=97 and s[j]<=122)){
11+
if(s[i]>=48 and s[i]<=57){
12+
if(s[i]==s[j]){
13+
i++;
14+
j--;
15+
}else{
16+
return false;
17+
}
18+
}
19+
else if((s[i]>=65 and s[i]<=90) or (s[i]>=97 and s[i]<=122)){
20+
if(s[i]==s[j] or s[i]+32==s[j] or s[i]==s[j]+32){
21+
i++;
22+
j--;
23+
}
24+
else{
25+
return false;
26+
}
27+
}
28+
29+
30+
}
31+
else{
32+
j--;
33+
}
34+
}else{
35+
i++;
36+
}
37+
}
38+
if(i>j){
39+
return true;
40+
}else{
41+
return false;
42+
}
43+
44+
45+
}
46+
};

0 commit comments

Comments
 (0)