求問(wèn)兩個(gè)字符串是否由完全相同的字母不同的組合而成,用python的count判斷每個(gè)字出現(xiàn)次數(shù)
#242
#Runtime: 20 ms (Beats 96.2%)
#Memory: 13.7 MB (Beats 69.85%)
class Solution(object):
def isAnagram(self, s, t):
"""
:type s: str
:type t: str
:rtype: bool
"""
if len(s) != len(t):
return False
for i in set(s):
if s.count(i) != t.count(i):
return False
return True