Skip to content

Commit 1f5f044

Browse files
committed
Update valid-palindrome.cpp
1 parent 1fc8037 commit 1f5f044

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

C++/valid-palindrome.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ class Solution2 {
2828
bool isPalindrome(string s) {
2929
auto left = s.begin();
3030
auto right = prev(s.end());
31-
for(; left < right;) {
32-
if(!isalnum(*left)) {
31+
while (left < right) {
32+
if (!isalnum(*left)) {
3333
++left;
34-
} else if(!isalnum(*right)) {
34+
} else if (!isalnum(*right)) {
3535
--right;
36-
} else if(tolower(*left) != tolower(*right)) {
36+
} else if (tolower(*left) != tolower(*right)) {
3737
return false;
3838
} else {
3939
++left, --right;

0 commit comments

Comments
 (0)