Valid Anagram
Difficulty: Easy · Topic: Hashing
Given two strings s and t, return True if t is an anagram of s — i.e. it uses exactly the same letters with the same counts.
Examples
is_anagram("anagram", "nagaram")
→ trueis_anagram("rat", "car")
→ falseis_anagram("a", "a")
→ trueTarget complexity: time O(n), space O(1)
Write your solution in Python and run it against hidden tests right on this page. Progressive hints and Python + C++ reference solutions are included.
Learn the idea first: the lesson for this problem.