Skip to content

Commit a6c3d2d

Browse files
committed
1
1 parent d421998 commit a6c3d2d

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

ValidPalindrome/ValidPalindrome.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ class Solution {
33
bool isPalindrome(string s) {
44
// Start typing your C/C++ solution below
55
// DO NOT write int main() function
6+
67
string alphas;
8+
79
for (size_t i = 0; i < s.size(); i++) {
810
if ('A' <= s[i] && s[i] <= 'Z')
911
alphas += s[i] - 'A' + 'a';
@@ -12,9 +14,12 @@ class Solution {
1214
else if ('0' <= s[i] && s[i] <= '9')
1315
alphas += s[i];
1416
}
17+
1518
if (alphas.size() == 0)
1619
return true;
20+
1721
size_t beg = 0, end = alphas.size() - 1;
22+
1823
while (beg < end) {
1924
if (alphas[beg] == alphas[end]) {
2025
beg += 1;
@@ -25,4 +30,4 @@ class Solution {
2530
}
2631
return true;
2732
}
28-
};
33+
};

0 commit comments

Comments
 (0)