-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path125.cpp
46 lines (42 loc) · 1.12 KB
/
125.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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;
}
}
};