Back to course home
0% completed
Vote For New Content
Using hashmap, concise solution
amazonintern101
Aug 14, 2023
class Solution: def isAnagram(self, s, t): # TODO: Write your code here charSet = {} if len(s) != len(t): return False for char in s: if char not in charSet: charSet[char] = 0 else: charSet[char] += 1 for char in t: if char not in charSet: return False else: if charSet[char] >= 0: charSet[char] -= 1 else: return False return True
0
0
Comments
Comments