File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change 7
7
## Week 1 🚧
8
8
1 . [ Detect Capital] ( https://leetcode.com/explore/challenge/card/august-leetcoding-challenge/549/week-1-august-1st-august-7th/3409/ ) ➡️ [ CPP Solution] ( Week1/detectCapital.cpp )
9
9
2 . [ Design HashSet] ( https://leetcode.com/explore/challenge/card/august-leetcoding-challenge/549/week-1-august-1st-august-7th/3410/ ) ➡️ [ CPP Solution] ( Week1/designHashset.cpp )
10
+ 3 . [ Valid Palindrome] ( https://leetcode.com/explore/challenge/card/august-leetcoding-challenge/549/week-1-august-1st-august-7th/3411/ ) ➡️ [ CPP Solution] ( Week1/validPalindrome.cpp )
10
11
11
12
## Where to find me? 🌟
12
13
* [ Website] ( https://akashwho.codes/ )
Original file line number Diff line number Diff line change
1
+ class Solution {
2
+ public:
3
+ bool isPalindrome (string s) {
4
+ if (s.empty () || s.size () == 1 ) return true ;
5
+
6
+ int i = 0 ;
7
+ int j = s.size () - 1 ;
8
+
9
+ while (i <= j) {
10
+ while (!isalnum (s[i]) && i < j) i++;
11
+ while (!isalnum (s[j]) && i < j) j--;
12
+
13
+ if (tolower (s[i]) != tolower (s[j])) return false ;
14
+
15
+ i++;
16
+ j--;
17
+ }
18
+
19
+ return true ;
20
+ }
21
+ };
You can’t perform that action at this time.
0 commit comments