欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

leetcode1

程序员文章站 2024-03-09 11:51:41
...

leetcode1

class Solution(object):
    def twoSum(self, nums, target):
        """
        :type nums: List[int]
        :type target: int
        :rtype: List[int]
        """
        d = {}
        for i,items in enumerate(nums):
            tmp = target - items
            for key,value in d.items():
                if value == tmp:
                    return [key, i]
            d[i] = items
        return None