Skip to content

Commit db84238

Browse files
author
mykoo
committed
valid-anagram
1 parent 559dfdb commit db84238

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

valid-anagram/GUMUNYEONG.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/**
2+
* @param {string} s
3+
* @param {string} t
4+
* @return {boolean}
5+
*/
6+
var isAnagram = function (s, t) {
7+
const countHash = {};
8+
let result = true;
9+
10+
if (s.length !== t.length) return false;
11+
12+
for (str_t of t) {
13+
countHash[str_t] ? countHash[str_t]++ : countHash[str_t] = 1;
14+
}
15+
16+
for (str_s of s) {
17+
if (countHash[str_s]) {
18+
countHash[str_s]--;
19+
} else {
20+
result = false;
21+
break;
22+
}
23+
}
24+
25+
return result;
26+
};

0 commit comments

Comments
 (0)