lc001.两数之和

 

题目链接

迷惑的我,做了好几次了还卡着好久,真的💊

class Solution:

    def twoSum(self, nums: List[int], target: int) -> List[int]:
        dic = {}
        for key, value in enumerate(nums):
            if dic.get(target - value) is not None:
                return [key, dic[target-value]]
            else:
                dic[value] = key