We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 77e3381 commit 84c6eefCopy full SHA for 84c6eef
two-sum/JiHyeonSu.py
@@ -0,0 +1,11 @@
1
+# 해시맵을 활용한 두 수의 합 구현
2
+# 시간복잡도 및 공간복잡도 O(n)
3
+class Solution:
4
+ def twoSum(self, nums: List[int], target: int) -> List[int]:
5
+ n_map = {}
6
+
7
+ for i, num in enumerate(nums):
8
+ diff = target - num
9
+ if diff in n_map:
10
+ return [n_map[diff], i]
11
+ n_map[num] = i
0 commit comments