首页 > 其他 > 详细

Two Sum

时间:2016-10-06 21:58:13      阅读:154      评论:0      收藏:0      [点我收藏+]

题目如下:

技术分享

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

原文:http://www.cnblogs.com/CQUTWH/p/5934600.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!