LyWang

twosum

Nov 25th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.32 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.         for u in range(len(nums)-1):
  9.            if (target-nums[u]) in nums[u+1:]:
  10.               j=nums[u+1:].index(target-nums[u])+u+1
  11.               return [u,j]
Add Comment
Please, Sign In to add comment