← All problems
Valid Anagram
Given two strings s and t, determine whether t is an anagram of s — that is, whether t can be formed by rearranging exactly the letters of s. Both strings contain only lowercase English letters in the follow-up; solve the general case first.
Complexity
Time O(n), Space O(1) for fixed alphabet
Common pitfalls
- Sorting is O(n log n) - fine but slower
- Case sensitivity assumptions
Your solution
Log in to save your code and track progress.