Palindrome Check That Ignores Spaces, Symbols and Letter Case
Company: Walmart Labs
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: easy
Interview Round: Onsite
Overview: Decide whether a string is a palindrome when spaces, punctuation and letter case are ignored and only letters and digits are compared. It tests string scanning with character filtering, case normalization and edge cases such as strings that contain no letters or digits at all.
Read the full Walmart Labs Software Engineer interview experience this question came from
Constraints
- 0 <= len(s) <= 2 * 10^5
- s contains only printable ASCII characters (codes 32 through 126).
Examples
Input: ('',)
Expected Output: True
Explanation: Empty string (length 0): nothing is compared, so it counts as a palindrome.
Input: ('a',)
Expected Output: True
Explanation: A single letter is a palindrome.
Hints
- Settle first which characters take part in the comparison: only a-z, A-Z and 0-9. Everything else, including characters such as '_', '@' or '[', is ignored.
- An uppercase letter and its lowercase form count as the same character. Digits have no case, so '0' never equals 'P'.
- If nothing is left once the ignored characters are removed, the answer is True.