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 e0d7d23 commit 04e7e83Copy full SHA for 04e7e83
โvalid-anagram/anniemon.js
@@ -0,0 +1,29 @@
1
+/**
2
+ * ์๊ฐ ๋ณต์ก๋:
3
+ * s์ t์ ๊ธธ์ด๋งํผ ๊ฐ ๋ฌธ์์ ์นด์ดํธ๋ฅผ ๊ธฐ๋กํ๊ณ ์ด๋ฅผ ํ์ธํ๋ฏ๋ก, ์๊ฐ ๋ณต์ก๋๋ O(n)
4
+ * ๊ณต๊ฐ ๋ณต์ก๋:
5
+ * ์นด์ดํธ ๊ฐ์ฒด๋ ์ต๋ s์ t์ ๊ธธ์ด๋งํผ ๊ณต๊ฐ์ ์ฐจ์งํ๋ฏ๋ก, ๊ณต๊ฐ ๋ณต์ก๋๋ O(n)
6
+ */
7
8
+ * @param {string} s
9
+ * @param {string} t
10
+ * @return {boolean}
11
12
+var isAnagram = function (s, t) {
13
+ if (s.length !== t.length) {
14
+ return false;
15
+ }
16
+
17
+ const count = {};
18
+ for (let i = 0; i < s.length; i++) {
19
+ count[s[i]] = (count[s[i]] || 0) + 1;
20
+ count[t[i]] = (count[t[i]] || 0) - 1;
21
22
23
+ for (const key in count) {
24
+ if (count[key] !== 0) {
25
26
27
28
+ return true;
29
+};
0 commit comments