diff --git a/climbing-stairs/FEhyoeun.ts b/climbing-stairs/FEhyoeun.ts new file mode 100644 index 000000000..99dde82d0 --- /dev/null +++ b/climbing-stairs/FEhyoeun.ts @@ -0,0 +1,13 @@ +const cache: number[] = []; + +function climbStairs(n: number): number { + if(n === 1) return 1 + if(n === 2) return 2; + + // cache 값 있을 때 + if(cache[n]) return cache[n] + + // cache 값 없을 때 + cache[n] = climbStairs(n - 1) + climbStairs(n - 2); + return cache[n] +}; diff --git a/valid-anagram/FEhyoeun.ts b/valid-anagram/FEhyoeun.ts new file mode 100644 index 000000000..f82d6a031 --- /dev/null +++ b/valid-anagram/FEhyoeun.ts @@ -0,0 +1,22 @@ +function isAnagram(s: string, t: string): boolean { + let sObj = {} + let tObj = {} + + s.split('').sort().map((sChar) => { + if(sChar in sObj) { + sObj[sChar] += 1 + } else { + sObj[sChar] = 1 + } + }) + + t.split('').sort().map((tChar) => { + if(tChar in tObj) { + tObj[tChar] += 1 + } else { + tObj[tChar] = 1 + } + }) + + return JSON.stringify(sObj) === JSON.stringify(tObj) +};