class Solution:
def isAnagram(self, s, t):
"""
:type s: str
:type t: str
:rtype: bool
"""
def construct_dict(a_string):
a_dict={}
for i in range(len(a_string)):
if a_string[i] in a_dict:
a_dict[a_string[i]] += 1
else:
a_dict[a_string[i]] = 1
return a_dict
dict_1 = construct_dict(s)
dict_2 = construct_dict(t)
if dict_1 == dict_2:
return True
else:
return False
No comments:
Post a Comment