fork download
  1. # your code goes here
  2. class Solution(object):
  3. def twoSum(self, nums, target):
  4. """
  5. :type nums: List[int]
  6. :type target: int
  7. :rtype: List[int]
  8. """
  9. m ={}
  10. for i in range(len(nums)):
  11. m[nums[i]] = i
  12.  
  13. for i in range(len(nums)):
  14. if target - nums[i] in m and m[target - nums[i]]!=i:
  15. return [i, m[target-nums[i]]]
  16.  
  17.  
  18.  
Success #stdin #stdout 0.07s 13984KB
stdin
Standard input is empty
stdout
Standard output is empty