File tree Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Original file line number Diff line number Diff line change 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+ };
You can’t perform that action at this time.
0 commit comments