Valid Anagram
easy · frequency counting
Return whether a and b contain exactly the same characters with the same multiplicities. Order does not matter; case, spaces, and Unicode characters do matter. Do not normalize the text. Empty strings are anagrams of each other. Each string has at most 1000 characters.
Examples (JSON; null means Python None):
Input: {"a": "anagram", "b": "nagaram"}
Output: true
Input: {"a": "rat", "b": "car"}
Output: false
Starter code
def valid_anagram(a: str, b: str) -> bool:
"""Compare exact character multiplicities."""
pass
Loading editor…
Each test has a five-second execution limit. Your practice drafts and solved progress stay in this browser.
Return to the Python compiler