Skip to content
RED SAGSkills

Alphanumeric Palindrome Check

A phrase counts as a palindrome if, after ignoring every character that is not a letter or digit and treating upper and lower case as equal, it reads the same forwards and backwards.

Return true if s is such a palindrome, otherwise false. An empty phrase is a palindrome.

Example 1

Input: s = "Never odd, or even."
Output: true

Example 2

Input: s = "deploy on friday"
Output: false

Constraints

  • 0 <= s.length <= 2 * 10^5
  • s contains printable ASCII characters.
Hint 1

Use one pointer at each end and move them toward each other.

Hint 2

Skip characters that are not letters or digits before comparing.

Good practice for: Frontend Developer, Backend Developer, Full Stack Developer, Mobile App Developer, Game Developer, Automation Test Engineer

Run checks your code on 2 sample tests. Submit runs all 8 tests, including hidden ones, and earns points. Use console.log to debug. Python's first run can take a few seconds while it starts.