Skip to content

Instantly share code, notes, and snippets.

@codeperfectplus
Last active August 29, 2023 09:34
Show Gist options
  • Select an option

  • Save codeperfectplus/f553a3fab48e3b9bd1e9e750d30979d2 to your computer and use it in GitHub Desktop.

Select an option

Save codeperfectplus/f553a3fab48e3b9bd1e9e750d30979d2 to your computer and use it in GitHub Desktop.
def twoSum(self, nums: List[int], target: int) -> List[int]:
seen = {}
for index, num in enumerate(nums):
other = target - num
if other in seen:
return[seen[other],index]
else:
seen[num] = index
return []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment