fork download
  1. # your code goes here
  2. class Solution:
  3. def isPalindrome(self, s: str) -> bool:
  4. s = "".join(ch.lower() for ch in s if ch.isalnum())
  5.  
  6. n = len(s)
  7. i, j = 0, n-1
  8.  
  9. for _ in range(n//2):
  10. # print(s[i], s[j])
  11. if s[i] != s[j]:
  12. return False
  13. i += 1
  14. j -= 1
  15.  
  16. return True
  17.  
Success #stdin #stdout 0.12s 14072KB
stdin
Standard input is empty
stdout
Standard output is empty