Skip to content

Commit ebd205a

Browse files
committed
Week 02: Valid anagram solution
1 parent 8d3ed21 commit ebd205a

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

valid-anagram/mandel-17.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class Solution:
2+
def isAnagram(self, s: str, t: str) -> bool:
3+
def count_char(target_str):
4+
dict_char = {}
5+
for c in target_str:
6+
dict_char[c] = dict_char.get(c, 0) + 1
7+
return dict_char
8+
9+
dict_s = count_char(s)
10+
dict_t = count_char(t)
11+
12+
if dict_s == dict_t:
13+
return True
14+
return False
15+

0 commit comments

Comments
 (0)