Skip to content

Commit e06a675

Browse files
committed
two-sum: 풀이 결과 요약
1 parent 938bce8 commit e06a675

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

two-sum/gyeo-ri.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
"""
2+
[결과 요약]
3+
# 재시도횟수: 3회
4+
1. 배열의 모든 경우의 수 계산하기
5+
- 시간복잡도 O(n^2)
6+
2. 전체 반복하지 않고 인덱스 기준 뒤만 반복하기
7+
- O(n^2)이지만 약간 더 효율적
8+
3. 딕셔너리(Map) 사용
9+
- 시간복잡도: O(n) / 공간복잡도: O(n)
10+
- 딕셔너리 자체는 빨리 떠올렸으나 Key 중복이 될 수 있다고 잘못 판단하여 시간을 오래 소모
11+
- 실제로 하나의 숫자는 최대 두 번까지 사용되어 구조 상 Key가 중복되지 않음
12+
"""
13+
14+
115
class Solution:
216
def twoSum(self, nums: list[int], target: int) -> list[int]:
317
nums_dict = {}

0 commit comments

Comments
 (0)