My LeetCode grinding. Trying to do a problem a day.
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

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"))