Check a Palindrome While Ignoring Case and Punctuation
Company: Amazon
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: easy
Interview Round: Technical Screen
Overview: Check whether a string is a palindrome after ignoring punctuation and letter case while retaining ASCII letters and digits.
Read the full Amazon Software Engineer interview experience this question came from
Constraints
- s contains printable ASCII characters with codes 32 through 126.
- 0 <= s.length <= 200000.
- Retain only A-Z, a-z and 0-9. Compare letters without regard to case.
- An empty retained sequence is a palindrome.
Examples
Input: ('A1, bB!1a',)
Expected Output: True
Explanation: Published sample 1: the retained sequence is a1bb1a.
Input: ('0P',)
Expected Output: False
Explanation: Published sample 2: the digit and letter remain distinct.