注意事项
python 的 ord
函数.
class Solution(object):
def isAnagram(self, s, t):
"""
:type s: str
:type t: str
:rtype: bool
"""
if(len(s)!=len(t)):
return False
table_s = [0]*26
table_t = [0]*26
for c in s:
idx = ord(c)-ord('a')
table_s[idx] +=1
for c in t:
idx = ord(c)-ord('a')
table_t[idx] +=1
for i in range(26):
if table_s[i]!=table_t[i]:
return False
return True