leetcode
This commit is contained in:
21
leetcode/242.py
Normal file
21
leetcode/242.py
Normal file
@@ -0,0 +1,21 @@
|
||||
class Solution:
|
||||
def isAnagram(self, s: str, t: str) -> bool:
|
||||
d={}
|
||||
|
||||
if not len(s)==len(t):
|
||||
return False
|
||||
for i in s:
|
||||
if i in d:
|
||||
d[i]+=1
|
||||
else:
|
||||
d[i]=1
|
||||
for i in t:
|
||||
if i in d:
|
||||
d[i]-=1
|
||||
else:
|
||||
return False
|
||||
|
||||
for i in d.keys():
|
||||
if not d[i]==0:
|
||||
return False
|
||||
return True
|
||||
Reference in New Issue
Block a user