Valid Anagram
Valid Anagram
Given two strings s and t, return true if t is an anagram of s, otherwise false.
Function signature
func IsAnagram(s, t string) bool
In Python, implement is_anagram(s, t).
Example
s = "anagram", t = "nagaram" -> true
s = "rat", t = "car" -> false
Constraints
- 0 <= len(s), len(t) <= 200_000
- Strings contain lowercase English letters
Aim for linear time in the total input length.
Try it before coding
The inputs "ccab" and "cabb" have the same length and the same set of letters. Which counts decide the answer?
Check your reasoning
The first has two c and one b. The second has one c and two b. Rearrangement preserves each count, so the answer is false.
Run tests to see results
No issues detected