Skip to content

Commit cee6cc2

Browse files
authored
feat : valid-anagram 풀이완료
1 parent 1eeeb32 commit cee6cc2

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

valid-anagram/Kyojin-Hwang.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* @param {string} s
3+
* @param {string} t
4+
* @return {boolean}
5+
*/
6+
var isAnagram = function(s, t) {
7+
if (s.length !== t.length) return false;
8+
9+
const count = {};
10+
11+
for (let char of s) {
12+
count[char] = (count[char] || 0) + 1;
13+
}
14+
15+
for (let char of t) {
16+
if (!count[char]) return false; // 없거나 개수가 0
17+
count[char]--;
18+
}
19+
20+
return true;
21+
};

0 commit comments

Comments
 (0)