Skip to content

Commit e1de42e

Browse files
authored
Add files via upload
1 parent 6a8eb40 commit e1de42e

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

125.Valid Palindrome.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
class Solution {
2+
public:
3+
bool isPalindrome(string s) {
4+
int left=0;
5+
int right=s.length()-1;
6+
7+
while (left<right)
8+
{
9+
while(left<right && !isalnum(s[left]))
10+
{
11+
left++;
12+
}
13+
while (left < right && !isalnum(s[right]))
14+
{
15+
right --;
16+
}
17+
if (tolower(s[left]) != tolower(s[right]))
18+
{
19+
return false;
20+
}
21+
left++;
22+
right--;
23+
}
24+
return true;
25+
}
26+
};

0 commit comments

Comments
 (0)