Anagram check
What is the fastest way to check whether two strings are anagrams, and its complexity?
Show hints (2)+
- Anagrams have identical multisets of characters.
- Counting beats sorting asymptotically.
Answer
Reveal answer →Final answer
Compare character-frequency counts — $O(n)$
Want the full step-by-step worked solution? It's part of Premium — along with a worked solution for every question in the bank.