Guest User

Untitled

a guest
Sep 19th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. class Solution:
  2. def twoSum(self, nums, target):
  3. """
  4. :type nums: List[int]
  5. :type target: int
  6. :rtype: List[int]
  7. """
  8. dict = {}
  9. for i in range(len(nums)):
  10. complement = target - nums[i]
  11. if complement in dict:
  12. return dict[complement], i
  13. dict[nums[i]] = i
Add Comment
Please, Sign In to add comment