Created
April 6, 2021 21:50
-
-
Save humpydonkey/1db6d9c5e0c5a2ffec5cf50716fbf96c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution: | |
def isPalindrome(self, s: str) -> bool: | |
l, r = 0, len(s)-1 | |
while l < r: | |
if not s[l].isalnum(): | |
l += 1 | |
elif not s[r].isalnum(): | |
r -= 1 | |
else: | |
if s[r].lower() != s[l].lower(): | |
return False | |
l += 1 | |
r -= 1 | |
return True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment