Easy
Valid Palindrome
👶 The 5-Year-Old Summary
Does "racecar" read the same forwards and backwards? Ignore spaces and punctuation! "A man, a plan, a canal: Panama" is a palindrome!
🎮 Interactive Visualizer
Input: "A man, a plan, a canal: Panama"
🧠 The Brain Hack
Two pointers! One at start, one at end. Move toward center, skipping non-alphanumeric. Compare characters at each step!
💻 The Clean Solution
def is_palindrome(s):
# Clean string: keep only alphanumeric, lowercase
clean = ''.join(c.lower() for c in s if c.isalnum())
# Two pointers
left, right = 0, len(clean) - 1
while left < right:
if clean[left] != clean[right]:
return False
left += 1
right -= 1
return True
# "A man, a plan, a canal: Panama" → True
Time: O(n)
Space: O(n) for clean string