Problem 1 and 2

This commit is contained in:
Simon Oberzier
2026-01-08 21:34:54 +01:00
parent 38460afca7
commit 293fee1fc5
2 changed files with 31 additions and 0 deletions

9
0001-two-sum/solution.py Normal file
View File

@@ -0,0 +1,9 @@
class Solution:
def twoSum(self, nums: List[int], target: int) -> List[int]:
dic = {}
for i, val in enumerate(nums):
if target - val in dic:
return [dic[target - val], i]
else:
dic[val] = i