text, return True if it is a mirror phrase and False otherwise.
Try to do it without building a copy of the string, in O(1) extra memory.text="Step on no pets!" → True
Keeping only the letters gives "steponnopets", which is the same in both directions.
text="Taco cat, 2 go" → False
After cleaning we get "tacocat2go". It starts with t but ends with o, so it is not a mirror.
text="?! .." → True
No letters or digits remain, and an empty string reads the same both ways.
text) ≤ 2 · 10⁵text consists of printable ASCII characterstext="Step on no pets!"
True
Run checks the first 3 tests in your browser. Submit checks all 5 tests on the server, hidden ones included.