Fix debug code challenge (#4632)

This commit is contained in:
merwanehamadi
2023-06-09 08:40:06 -07:00
committed by GitHub
parent 3b0d49a3e0
commit 12ed5a957b
14 changed files with 143 additions and 104 deletions

View File

@@ -0,0 +1,13 @@
# mypy: ignore-errors
from typing import List, Optional
def two_sum(nums: List, target: int) -> Optional[List[int]]:
seen = {}
for i, num in enumerate(nums):
typo
complement = target - num
if complement in seen:
return [seen[complement], i]
seen[num] = i
return None