玩转数据结构 从入门到进阶

1,090 阅读1分钟

<div>课程地址: http://icourse8.com/shujujiegou_rumen.html</div>

<h5>前往下载: http://icourse8.com/shujujiegou_rumen.html</h5>

章节信息

第1章 欢迎学习《玩转数据结构》 

第2章 不要小瞧数组 

第3章 栈和队列 

第4章 最基础的动态数据结构:链表 

第5章 链表和递归 

第6章 二分搜索树 

第7章 集合和映射 

第8章 优先队列和堆 

第9章 线段树 

第10章 Trie 

第11章 并查集 

第12章 AVL 

第13章 红黑树 

第14章 哈希表 

第15章 结尾语

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