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 d421998 commit a6c3d2dCopy full SHA for a6c3d2d
ValidPalindrome/ValidPalindrome.cpp
@@ -3,7 +3,9 @@ class Solution {
3
bool isPalindrome(string s) {
4
// Start typing your C/C++ solution below
5
// DO NOT write int main() function
6
+
7
string alphas;
8
9
for (size_t i = 0; i < s.size(); i++) {
10
if ('A' <= s[i] && s[i] <= 'Z')
11
alphas += s[i] - 'A' + 'a';
@@ -12,9 +14,12 @@ class Solution {
12
14
else if ('0' <= s[i] && s[i] <= '9')
13
15
alphas += s[i];
16
}
17
18
if (alphas.size() == 0)
19
return true;
20
21
size_t beg = 0, end = alphas.size() - 1;
22
23
while (beg < end) {
24
if (alphas[beg] == alphas[end]) {
25
beg += 1;
@@ -25,4 +30,4 @@ class Solution {
30
26
31
27
32
28
-};
33
+};
0 commit comments