Problem List
Go doesn't have a built-in counter or defaultdict like Python, so I had to roll my own hash map. Not a big deal, but worth noting. Felt like a pretty clean solution overall.
O(n) Each character is processed a constant number of times, so total time is linear in the length of the input.O(1)At most 26 characters for lowercase input → constant space usage.func isAnagram(s string, t string) bool {
if len(s) != len(t) {
return false
}
m := make(map[rune]int)
for _, letter := range s {
m[letter]++
}
for _, letter := range t {
m[letter]--
if m[letter] < 0 {
return false
}
}
return true
}