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 ac03a8d commit bfe9a6aCopy full SHA for bfe9a6a
valid-palindrome/mkwkw.cpp
@@ -1 +1,35 @@
1
-//set-up
+class Solution {
2
+public:
3
+ bool isPalindrome(string s) {
4
+
5
+ string str = "";
6
7
+ for(int i=0; i<s.length(); i++)
8
+ {
9
+ if(isalpha(s[i]))
10
11
+ str += tolower(s[i]);
12
+ }
13
+ else if (s[i]>='0' && s[i]<='9') //alpha"numeric"
14
15
+ str += s[i];
16
17
18
19
+ //Palindrome
20
+ if(s.length()==0 || s.length()==1)
21
22
+ return true;
23
24
25
+ for(int i=0; i<str.length()/2; i++)
26
27
+ if(str[i]!=str[str.length()-1-i])
28
29
+ return false;
30
31
32
33
34
35
+};
0 commit comments