Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution(object):
- def isPalindrome(self, s):
- left_bound = 0
- right_bound = len(s) - 1
- if right_bound == 0:
- return True
- while(left_bound < right_bound):
- if not s[left_bound].isalnum():
- left_bound += 1
- continue
- elif not s[right_bound].isalnum():
- right_bound -= 1
- continue
- if s[left_bound].lower() == s[right_bound].lower():
- left_bound += 1
- right_bound -= 1
- else:
- return False
- return True
Add Comment
Please, Sign In to add comment