Valid Anagram
- String
- Hash Map
- Frequency Counting
Given two lowercase English strings s and t, return true when t is an anagram of s.
An anagram uses every character from the original string exactly once, possibly in a different order.
Compound-word rearrangement
- Input
"s": "datastructures", "t": "structuredatas"
- Output
true
Explanation: Every letter occurs the same number of times in both strings.
One substituted letter
- Input
"s": "hashmap", "t": "hashpad"
- Output
false
Explanation: The first string contains m while the second contains d.
Constraints
- 0 <= s.length, t.length <= 100,000
- s and t contain lowercase English letters only
Follow-up
How would your approach change if the strings could contain arbitrary Unicode characters?