My LeetCode grinding. Trying to do a problem a day.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1234567891011121314
  1. # This problem was to check (case insensitively) if a given str is a palindrome
  2. class Solution:
  3. def isPalindrome(self, s: str) -> bool:
  4. newString = ""
  5. for c in s:
  6. if ord(c.lower()) <= 122 and ord(c.lower()) >= 97 or (ord(c) >= 48 and ord(c) <= 57):
  7. newString += c.lower()
  8. return newString == newString[::-1]
  9. s = Solution()
  10. print("Expect: True")
  11. print("Got:", s.isPalindrome("aba"))