python
class Solution:
def isAnagram(self, s: str, t: str) -> bool:
n_s = len(s)
n_t = len(t)
if n_s != n_t:
return False
char_freq = {}
for char in s:
if char in char_freq:
char_freq[char] += 1
else:
char_freq[char] = 1
for char in t:
if char not in char_freq:
return False
char_freq[char] -= 1
for freq in char_freq.values():
if freq != 0:
return False
return True