LeetCode——1两数之和

求两个数字之和等于target

class Solution:
    def twoSum(self, nums: List[int], target: int) -> List[int]:

        result = list()
        for i in range(len(nums)):
            for j in range(i+1, len(nums)):
                if i != j and (nums[i]+nums[j]) == target:
                    result.append(i)
                    result.append(j)
        
        return result
posted @ 2022-05-07 10:46  Lazy_tiger  阅读(23)  评论(0编辑  收藏  举报