Skip to content

Commit 8a202ea

Browse files
committed
feat: [easy] valid-anagram 문제 풀이
1 parent 1110f1e commit 8a202ea

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

valid-anagram/hyoeun-kim.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
function isAnagram(s: string, t: string): boolean {
2+
let sObj = {}
3+
let tObj = {}
4+
5+
s.split('').sort().map((sChar) => {
6+
if(sChar in sObj) {
7+
sObj[sChar] += 1
8+
} else {
9+
sObj[sChar] = 1
10+
}
11+
})
12+
13+
t.split('').sort().map((tChar) => {
14+
if(tChar in tObj) {
15+
tObj[tChar] += 1
16+
} else {
17+
tObj[tChar] = 1
18+
}
19+
})
20+
21+
return JSON.stringify(sObj) === JSON.stringify(tObj)
22+
};

0 commit comments

Comments
 (0)