Valid palindrome
A palindrome reads the same from left to right as from right to left, like "noon". You get a string s. Keep only its letters and digits, and treat uppercase and lowercase as the same letter. Return True if what is left is a palindrome, and False if it is not.
Spaces, punctuation and other symbols do not count, so "No, on" is a palindrome: its letters, in lowercase, are noon. Digits do count, and a digit never matches a letter. A string with no letters or digits at all is a palindrome too, because nothing is left to disagree.
s = "Top spot"OutputTrueKeeping letters and digits in lowercase leaves topspot, which reads the same both ways.
s = "Top spots"OutputFalsetopspots backwards is stopspot. The first and last letters already differ: t and s.
s = ", ."OutputTrueNo letters or digits are left, and an empty string reads the same both ways.
0 ≤ len(s) ≤ 2 × 105
sholds printable ASCII characters: letters, digits, spaces, punctuation and symbols such as$or@.
Plan it first
Write a line for each before you code, then say them out loud. Compare with the Approach tab afterwards.