We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1ae2729 commit 26ce291Copy full SHA for 26ce291
valid-palindrome/dylan-jung.cpp
@@ -0,0 +1,22 @@
1
+class Solution {
2
+public:
3
+ bool isPalindrome(string s) {
4
+ string p;
5
+ for(char const& c: s) {
6
+ if('A' <= c && c <= 'Z') {
7
+ p.push_back(c - 'A' + 'a');
8
+ }
9
+ else if('a' <= c && c <= 'z') {
10
+ p.push_back(c);
11
12
+ else if ('0' <= c && c <= '9') {
13
14
15
16
+ int start = 0, end = p.size()-1;
17
+ while(start <= end) {
18
+ if(p[start++] != p[end--]) return false;
19
20
+ return true;
21
22
+};
0 commit comments