Determine sanitized palindrome in string
Company: LinkedIn
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: HR Screen
Quick Answer: This question evaluates string manipulation, text sanitization, Unicode-aware character classification, and algorithmic complexity reasoning, and falls under the Coding & Algorithms domain.
Constraints
- 0 <= s.length <= 2 * 10^5
- s consists of printable ASCII characters (and may include Unicode letters/digits).
- A string with no alphanumeric characters is considered a palindrome.
Examples
Input: ("A man, a plan, a canal: Panama",)
Expected Output: True
Explanation: Sanitizes to 'amanaplanacanalpanama', which reads the same both ways.
Input: ("race a car",)
Expected Output: False
Explanation: Sanitizes to 'raceacar', which is not a palindrome.
Hints
- First normalize the string: keep only alphanumeric characters and lowercase them.
- After normalizing, a palindrome check is just comparing the sequence to its reverse — or use two pointers moving inward.
- Decide your edge-case policy up front: the empty/whitespace-only/punctuation-only cases should all return true.