Skip to content

Commit 4953d89

Browse files
committed
feat: easy 복잡도 계산 주석 추가
1 parent f032c1d commit 4953d89

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

climbing-stairs/sujeong-dev.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
/**
22
* @param {number} n
33
* @return {number}
4-
*/
4+
*
5+
* 시간복잡도 계산
6+
* 메모이제이션으로 n번째에는 n번째에 대한 부분만 연산되므로 O(n)
7+
*
8+
* 공간복잡도 계산
9+
* memo배열에 n번째 연산값들이 각 인덱스에 할당되므로 O(n)
10+
d */
511

612
var climbStairs = function (n, memo = []) {
713
if (memo[n] !== undefined) return memo[n];

valid-anagram/sujeong-dev.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,18 @@
22
* @param {string} s
33
* @param {string} t
44
* @return {boolean}
5+
*
6+
* 시간복잡도 계산
7+
* 문자열 s 길이만큼 Map에 set => n
8+
* 문자열 t 길이만큼 Map에 set => n
9+
* 따라서 O(n)
10+
*
11+
* 공간복잡도 계산
12+
* 문자열 s, t의 길이만큼 Map에 할당되니까 O(n)
513
*/
614
var isAnagram = function (s, t) {
715
if (s.length !== t.length) return false;
8-
16+
917
const frequencyMap = new Map();
1018

1119
for (const x of s) {

0 commit comments

Comments
 (0)