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.
2 parents f02b7bf + c690fd8 commit 45ea72eCopy full SHA for 45ea72e
valid-anagram/GUMUNYEONG.js
@@ -0,0 +1,30 @@
1
+/**
2
+ * @param {string} s
3
+ * @param {string} t
4
+ * @return {boolean}
5
+ */
6
+var isAnagram = function (s, t) {
7
+ const countHash = {};
8
+
9
+ if (s.length !== t.length) return false;
10
11
+ for (str_t of t) {
12
+ countHash[str_t] ? countHash[str_t]++ : countHash[str_t] = 1;
13
+ }
14
15
+ for (str_s of s) {
16
+ if (countHash[str_s]) {
17
+ countHash[str_s]--;
18
+ } else {
19
+ return false;
20
21
22
23
+ return true;
24
+};
25
26
+// TC : O(n)
27
+// n(=s의 길이 = t의 길이) 만큼 반복 하므로 On(n)
28
29
+// SC : O(n)
30
+// 최대크기 n(=s의 길이 = t의 길이)만큼인 객체를 생성하므로 공간 복잡도도 O(n)
0 commit comments