Skip to content

Commit 1090e32

Browse files
author
mykoo
committed
two-sum qhrwkqeh cnrk
1 parent 485bbf4 commit 1090e32

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

two-sum/GUMUNYEONG.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,12 @@ var twoSum = function (nums, target) {
3737
}
3838

3939
};
40+
41+
// TC : O(n)
42+
// 1. num 을 순회하며 numPair 객체를 만듦(num 길이 n)
43+
// 2. numPair 를 순회하며 키-값이 대칭되는 첫번째 쌍을 찾음 (numPair 길이 n)
44+
// 3. num을 순회하며 인덱스를 찾음 (num 길이 n)
45+
// O(3n) 따라서 시간복잡도는 O(n)
46+
47+
// SC : O(n)
48+
// 크기가 n만큼인 객체(numPair)를 생성하므로 공간 복잡도도 O(n)

0 commit comments

Comments
 (0)