classSolution:defisAnagram(self, s:str, t:str)->bool:"""
方法一,遍历替换
"""# 判断长度是否相等iflen(s)!=len(t):returnFalsefor word in s:
t = t.replace(word,'',1)returnlen(t)==0"""
方法二, 哈希表
"""from collections import Counter
s = Counter(s)
t = Counter(t)return s == t
"""
方法三,排序
"""returnsorted(s)==sorted(t)