Skip to content

Instantly share code, notes, and snippets.

@humpydonkey
Created April 6, 2021 21:50
Show Gist options
  • Save humpydonkey/1db6d9c5e0c5a2ffec5cf50716fbf96c to your computer and use it in GitHub Desktop.
Save humpydonkey/1db6d9c5e0c5a2ffec5cf50716fbf96c to your computer and use it in GitHub Desktop.
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