You’re building a search deduplication service for a large e-commerce marketplace (10M+ daily searches). Users often misspell or reorder characters when searching for SKUs and promo codes (e.g., "SAVE10" vs "10EVAS"). To reduce redundant indexing and improve cache hit rates, you need a fast function that determines whether two strings are anagrams under strict normalization rules.
Implement a function:
are_anagrams(s: str, t: str) -> boolReturn True if s and t are anagrams after applying the following rules:
s and ts = "Dormitory", t = "Dirty room!!"True"dormitory" and "dirtyroom"s = "promo-code-2026", t = "2026 code promo"True"promocode2026" and "2026codepromo"0 <= len(s), len(t) <= 2 * 10^5False.s = "Dormitory", t = "Dirty room!!"OutputTrueWhyAfter normalization both become the same multiset of letters: "dormitory" vs "dirtyroom".s = "fintech-2026", t = "fintech2027"OutputFalseWhyNormalization yields "fintech2026" and "fintech2027"; the digit counts differ (6 vs 7).0 <= len(s), len(t) <= 2 * 10^5Strings may contain any ASCII charactersComparison is case-insensitive and ignores non-alphanumeric characters