首页 > 代码库 > Two Sum

Two Sum

题目如下:

技术分享

Python代码:

def twoSum(self, nums, target):        """        :type nums: List[int]        :type target: int        :rtype: List[int]        """        temp = []        result = []        for i in range(len(nums)):            if temp.count(target-nums[i])!=0:                result.append(nums.index(target-nums[i]))                result.append(i)            if temp.count(nums[i])==0:                temp.append(nums[i])        return result

 

Two Sum