Skip to content

Commit

Permalink
feat: two-sum
Browse files Browse the repository at this point in the history
  • Loading branch information
HodaeSsi committed Dec 28, 2024
1 parent 834ca1e commit c032266
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions two-sum/HodaeSsi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# 시간복잡도 : O(n)
# 공간복잡도 : O(n)
class Solution:
def twoSum(self, nums: List[int], target: int) -> List[int]:
seen = {} # {num: idx, ...}

for i, num in enumerate(nums):
if target - num in seen:
return [seen[target - num], i]
seen[num] = i

return []

0 comments on commit c032266

Please sign in to comment.