LeetCode 242, Easy. Topics: Hash Table, String, Sorting. View on LeetCode.
Generate this problem as a practice environment: tested reference solution, 18 parametrized pytest cases, and a playground notebook:
Problem
Given two strings s and t, return true if t is an anagram of s, and false otherwise.
Examples
Constraints
- 1 <= s.length, t.length <= 5 * 10^4
- s and t consist of lowercase English letters.
Follow up: What if the inputs contain Unicode characters? How would you adapt your solution to such a case?
Solution
Reference implementation from solution.py on GitHub, full suite in test_solution.py:
Complexity
Grind 75, Grind, Blind 75, NeetCode 150, NeetCode 250, NeetCode All. Last modified on September 7, 2026