-
[日常 LeetCode] 1.Two Sum
2019-04-02 11:44class Solution:
def twoSum(self, nums, target):
"""
:type nums: List[int]
:type target: int
:rtype: List[int]
"""for i in nums: if nums.count(i)>1 and target == i*2 : start=nums.index(i) del nums[start] last=nums.index(i)+1 return [start,last] if (target - i) in nums and (target-i) !=i: return [nums.index(i), nums.index(target - i)]
只能击败 35% 的人