We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 8ebdacb commit 53e95d1Copy full SHA for 53e95d1
Valid Palindrome/program.cpp
@@ -0,0 +1,36 @@
1
+class Solution {
2
+public:
3
+ bool isPalindrome(string s)
4
+ {
5
+ if(s==" ")
6
7
+ return true;
8
+ }
9
+ vector<char>st;
10
+ for(int i=0;i<s.length();i++)
11
12
+ if( (s[i]>='a'&& s[i]<='z') || (s[i]>='A' && s[i]<='Z') || (s[i]>='0'&& s[i]<='9') )
13
14
+ st.push_back(tolower(s[i]));
15
16
17
+ vector<char>strev;
18
+ copy(st.begin(),st.end(), back_inserter(strev));
19
+ reverse(strev.begin(), strev.end());
20
+
21
+ int f=0;
22
+ for(int i=0;i<st.size();i++)
23
24
+ if(st[i]!=strev[i])
25
26
+ f=1;
27
+ break;
28
29
30
+ if(f==0)
31
32
33
34
+ return false;
35
36
+};
0 commit comments