首页 > 代码库 > python letcode 1

python letcode 1

开始刷 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