Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 97aed5a

Browse files
authored
Create isAnagram.py
1 parent a3d8c9b commit 97aed5a

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Arrays/isAnagram.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class Solution:
2+
def isAnagram(self, s: str, t: str) -> bool:
3+
_len = len(s)
4+
_len2 = len(t)
5+
if _len != _len2:
6+
return False
7+
_list = [0 for i in range(26)]
8+
_list2 = [0 for i in range(26)]
9+
for i in range(_len):
10+
_list[ord(s[i])-ord('a')] += 1
11+
_list2[ord(t[i])-ord('a')] += 1
12+
return tuple(_list) == tuple(_list2)

0 commit comments

Comments
 (0)