LeetCode solutions

125. Valid Palindrome

My accepted Python solution to LeetCode problem 125, Valid Palindrome, running in 7ms.

  • Difficulty: Easy
  • Python
  • Runtime 7ms
  • Memory 22.5MB

Read the problem on LeetCode View on GitHub

Python

Accepted on LeetCode — runtime 7ms, memory 22.5MB, accepted 2025-12-23.

python
class Solution:
    def isPalindrome(self, s: str) -> bool:
        # Filter only alphanumeric characters and convert to lowercase
        cleaned = ''.join(c.lower() for c in s if c.isalnum())
        return cleaned == cleaned[::-1]

Source