You’re building a text-ingestion service for a fintech company that processes customer support messages for dispute resolution and regulatory audits. The pipeline handles tens of millions of messages/day, and a downstream classifier relies on a fast, deterministic check to flag messages that read the same forward and backward after normalization (a common signal in spam and obfuscation).
Because these messages may contain punctuation, whitespace, and mixed casing, your palindrome check must be normalization-aware and efficient.
Implement a function:
s: strboolReturn True if s is a palindrome after applying the following normalization rules:
[A-Z], [a-z], [0-9].A palindrome reads the same forward and backward after normalization.
s = "A man, a plan, a canal: Panama"True"amanaplanacanalpanama", which equals its reverse.s = "race a car"False"raceacar". Comparing ends: r != a, so it’s not a palindrome.True.0 <= len(s) <= 2 * 10^5s contains printable ASCII characters