-
Notifications
You must be signed in to change notification settings - Fork 0
LC 0001 [E] Two Sum 2Sum
Code with Senpai edited this page Jan 6, 2022
·
1 revision
class Solution:
def twoSum(self, nums: List[int], target: int) -> List[int]:
addend_to_index = {}
for i in range(len(nums)):
addend = target - nums[i]
if addend in addend_to_index:
return [addend_to_index[addend], i]
else:
addend_to_index[nums[i]] = i
footer