首页 > 编程语言 > 详细

python letcode 1

时间:2016-09-08 00:35:54      阅读:162      评论:0      收藏:0      [点我收藏+]

开始刷 letcode, 简单笔记下自己的答案, 目标十一结束之前搞定所有题目.

1. Two Sum.

class Solution(object):
    def twoSum(self, nums, target):
        """
        :type nums: List[int]
        :type target: int
        :rtype: List[int]
        """
        tmp = []
        for i, j in enumerate(nums):
                tmp.append((i, j))
                
        for k, item in enumerate(tmp):
            l, m = item
            for o, p in tmp[k+1:]:
                if m + p == target:
                    return sorted((l, o))

 

python letcode 1

原文:http://www.cnblogs.com/senjougahara/p/5850431.html

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