Back to Practice
#0221

Check Normalized Anagrams

EasyPython15 min10 XP

Problem

Return True if two strings are anagrams after keeping only letters and lowercasing them.

Why This Matters

Anagram checks teach the counting pattern behind many frequency-map interview problems.

Function Signature

def are_anagrams(a, b):

Examples

Example 1
Inputa = "Dormitory!!", b = "Dirty room"
OutputTrue

Both normalize to the same letters: dirtyroom.

Constraints

  • Return the exact requested value.
  • Handle edge cases cleanly.
  • Prefer readable Python before micro-optimizing.
CodePython
Visible browser tests run here when available.
Testcases1 visible / 3 hidden categories
Core example
Inputa = "Dormitory!!", b = "Dirty room"
ExpectedTrue

Both normalize to the same letters: dirtyroom.

Hidden Test Categories
different letter countsmixed casepunctuation-only strings