Skip to content

Commit 95be856

Browse files
authored
Merge pull request #2036 from FEhyoeun/main
[FEhyoeun] WEEK 02 solutions
2 parents de8ae3d + b01184c commit 95be856

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

β€Žclimbing-stairs/FEhyoeun.tsβ€Ž

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
const cache: number[] = [];
2+
3+
function climbStairs(n: number): number {
4+
if(n === 1) return 1
5+
if(n === 2) return 2;
6+
7+
// cache κ°’ μžˆμ„ λ•Œ
8+
if(cache[n]) return cache[n]
9+
10+
// cache κ°’ 없을 λ•Œ
11+
cache[n] = climbStairs(n - 1) + climbStairs(n - 2);
12+
return cache[n]
13+
};

β€Žvalid-anagram/FEhyoeun.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)