码迷,mamicode.com
首页 > 编程语言 > 详细

python letcode 1

时间:2016-09-08 00:37:45      阅读:416      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!