FreeCareerPath
Build the PrimitiveEasy

Valid Anagram

Write `is_anagram(a, b)` that returns `True` when the two strings contain exactly the same characters with the same multiplicities. is_anagram("listen", "silent") -> True is_anagram("rat", "car") -> False Sorting both strings is the obvious answer and it is O(n log n). Counting is O(n). Interviewers ask this one to see whether you reach for the cheaper structure without being told to.

What to expect: A timer starts when you begin. Edit the starter code, run it against the test suite as many times as you like, then finish when you're done. The reference solution and interviewer follow-up questions unlock only after you finish.

Log in to start this session

Timed sessions and your results for "Valid Anagram" are saved to your account — logging in takes a few seconds.

Valid Anagram — FreeCareerPath