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 a70f1b6 commit ad62cd8Copy full SHA for ad62cd8
valid-anagram/juhui-jeong.ts
@@ -0,0 +1,27 @@
1
+// 시간 복잡도(Time Complexity): O(n)
2
+// 공간 복잡도(Space Complexity): O(1)
3
+function isAnagram(s: string, t: string): boolean {
4
+ if (s.length !== t.length) return false;
5
+
6
+ const count = new Array(26).fill(0);
7
8
+ for (let i = 0; i < s.length; i++) {
9
+ count[s.charCodeAt(i) - 97]++;
10
+ count[t.charCodeAt(i) - 97]--;
11
+ }
12
13
+ return count.every((n) => n === 0);
14
+}
15
16
+/*
17
+// 첫 번째 풀이
18
+// 시간 복잡도(Time Complexity): O(n log n)
19
+// 공간 복잡도(Space Complexity): O(n)
20
21
22
+ let baseString = s.split('').sort().toString();
23
+ let targetString = t.split('').sort().toString();
24
25
+ return baseString === targetString ? true : false;
26
27
+*/
0 commit comments