Skip to the code
cf.
+10 XP

#96 Mirror-Readable Layer Name

easy

A design tool shows a small badge next to any layer whose name reads the same forwards and backwards. Only letters and digits count: spaces, dashes, and other symbols are ignored, and upper and lower case letters count as the same.

Write isMirrorName(name) that returns true if name reads the same both ways under these rules, and false otherwise. A name with no letters or digits at all counts as mirror-readable.

Example 1

Input: name = "Top-Spot"
Output: true

Keeping only letters gives topspot, which reads the same both ways.

Example 2

Input: name = "Card 12"
Output: false

card12 backwards is 21drac.

Constraints

  • 0 <= name.length <= 100000
  • name contains printable ASCII characters.
Saved in this browser

Run tries your code on the examples. Submit runs every test, including hidden edge cases, and solves the problem when they all pass.

Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).