Skip to content

Instantly share code, notes, and snippets.

@Desolve
Last active June 28, 2019 11:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Desolve/e936fe7cbad8aa7810eeffacebadda41 to your computer and use it in GitHub Desktop.
Save Desolve/e936fe7cbad8aa7810eeffacebadda41 to your computer and use it in GitHub Desktop.
0001 Two Sum
class Solution:
def twoSum(self, nums: 'List[int]', target: 'int') -> 'List[int]':
numMap = {}
for i in range(len(nums)):
if numMap.__contains__(target-nums[i]):
return [numMap.get(target-nums[i]), i]
else:
numMap[nums[i]] = i
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment