class Solution:
def isAnagram(self, s: str, t: str) -> bool:
temp1 = {}
temp2 = {}
for i in s:
temp1[i] = s.count(i)
for j in t:
temp2[j] = t.count(j)
return (temp1 == temp2)
方案二:
class Solution:
def isAnagram(self, s: str, t: str) -> bool:
return sorted(s) == sorted(t)
轉載自:https://blog.csdn.net/isabloomingtree/article/details/106420670