Advertisement
Guest User

Untitled

a guest
Dec 16th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. def twoSum(self, nums, target):
  2.  
  3. dict = {}
  4.  
  5. for i in range(len(nums)):
  6. dict[nums[i]] = i
  7.  
  8. for j in range(len(nums)):
  9. other = target - nums[j]
  10. if other in dict.keys() and dict[other] != j:
  11. return [j, dict[other]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement