LeetCode 1. Two Sum 解答

视频讲解

代码

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

        cache = dict()
        for idx, num in enumerate(nums):
            if target - num in cache:
                return [idx, cache[target - num]]
            else:
                cache[num] = idx

PPT讲解

本题涉及的知识点:

我的 Leetcode 讲解频道

代码链接

面试高频考点Youtube链接

面试低频考点Youtube链接

站内搜索 | Search


    视频 | Video Links

    Table of Contents