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 1f51b19 commit 388a7e6Copy full SHA for 388a7e6
1 file changed
valid-anagram/hyeri0903.py
@@ -0,0 +1,29 @@
1
+class Solution:
2
+ def isAnagram(self, s: str, t: str) -> bool:
3
+ """
4
+ Determine whether two strings are anagrams.
5
+
6
+ Time Complexity: O(n)
7
+ Space Complexity: O(k)
8
+ - n: length of the string
9
+ - k: number of unique characters
10
11
+ if len(s) != len(t):
12
+ return False
13
14
+ dic_s = {}
15
+ dic_t = {}
16
17
+ for i in s:
18
+ if i in dic_s:
19
+ dic_s[i] += 1
20
+ else:
21
+ dic_s[i] = 1
22
23
+ for j in t:
24
+ if j in dic_t:
25
+ dic_t[j] += 1
26
27
+ dic_t[j] = 1
28
29
+ return dic_s == dic_t
0 commit comments