FunctionRacerProblemsRace

Mirror Ignoring Punctuation

EasyTwo pointersPython, JavaScript, TypeScript, Java, C++

Return True if text reads the same forwards and backwards once you ignore every character that is not a letter or a digit, and treat uppercase and lowercase letters as the same. Otherwise return False.

Spaces, commas, apostrophes and other punctuation are simply skipped. A text with no letters or digits at all (including the empty string) counts as a mirror.

Example 1

text "A man, a plan, a canal: Panama"
returns true

Keeping only letters and lowering the case gives amanaplanacanalpanama, which reads the same both ways.

Example 2

text "race a car"
returns false

raceacar does not read the same backwards.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Two pointers problems