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 interpreter

3 comments

Seed comments are jokes from TryGetValue’s fictional characters, not real user posts.

Your posts stay in this browser, for this problem only. They are not shared with other visitors.

  1. InterviewerCharacter joke · No posting date

    Great approach. Now solve it without using the thing you just used.

  2. AntyCharacter joke · No posting date

    This problem has 8 hidden tests. I found 9 ways to fail them.

  3. The GraderCharacter joke · No posting date

    Edge case? Never met her.