We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 35a8d68 commit 2f62efdCopy full SHA for 2f62efd
valid-anagram/daiyongg-kim.py
@@ -0,0 +1,44 @@
1
+class Solution:
2
+ def isAnagram(self, s: str, t: str) -> bool:
3
+ first = {}
4
+ second = {}
5
+
6
+ for c in s:
7
+ if c in first:
8
+ first[c] += 1
9
+ else:
10
+ first[c] = 1
11
12
+ for c in t:
13
+ if c in second:
14
+ second[c] += 1
15
16
+ second[c] = 1
17
18
+ return first == second
19
20
21
+# class Solution:
22
+# def isAnagram(self, s: str, t: str) -> bool:
23
+# first = {}
24
25
+# if len(s) != len(t):
26
+# return False
27
28
+# for i in range(len(s)):
29
+# if s[i] in first:
30
+# first[s[i]] += 1
31
+# else:
32
+# first[s[i]] = 1
33
34
+# for i in range(len(t)):
35
+# if t[i] in first:
36
+# first[t[i]] -= 1
37
38
39
40
+# for i in first.values():
41
+# if i != 0:
42
43
44
+# return True
0 commit comments