https://leetcode.com/problems/binary-tree-level-order-traversal-ii/ 层序遍历,然后把结果反一下返回值就可以了 最后一步有问题,reverse()函数没有返回值,应该使用 res[::-1] Runtime: 44 ms, faste ...
分类:
其他好文 时间:
2019-01-29 00:35:30
阅读次数:
141
表示“重复”这个含义的词有很多, 比如循环(loop), 递归(recursion), 遍历(traversal), 迭代(iterate).循环算是最基础的概念, 凡是重复执行一段代码, 都可以称之为循环. 大部分的递归, 遍历, 迭代, 都是循环. 递归是重复调用函数自身实现循环。 迭代是函数内 ...
分类:
其他好文 时间:
2019-01-27 21:46:28
阅读次数:
214
题目: Suppose that all the keys in a binary tree are distinct positive integers. Given the postorder and inorder traversal sequences, you are supposed t ...
分类:
其他好文 时间:
2019-01-27 19:03:00
阅读次数:
168
1. Queue Python中,使用collections.deque,双端队列 2. 图的BFS BFS中可能用到的HashSet(C++: unordered_map, Python: dict) 常用邻接表存储。邻接矩阵太大了... 邻接表定义: 1. 自定义的方法,更加工程化。所以在面试中 ...
分类:
其他好文 时间:
2019-01-26 21:41:02
阅读次数:
201
Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level). For example:Given binary tree [3 ...
分类:
其他好文 时间:
2019-01-13 16:12:42
阅读次数:
196
Given a Binary Search Tree (BST) with the root node root, return the minimum difference between the values of any two different nodes in the tree. Exa ...
分类:
其他好文 时间:
2019-01-10 17:45:12
阅读次数:
115
有了我们的消费者和生产者代码,我们需要来验证一下它们的正确性,照常理来说我们直接创建一些消费者和生产者的线程让它们执行就可以了啊,但是为了“加分”考虑呢,我们还是使用线程池吧..也不是特别复杂:
分类:
其他好文 时间:
2019-01-10 12:05:03
阅读次数:
174
Given a binary tree, return the vertical order traversal of its nodes' values. (ie, from top to bottom, column by column). If two nodes are in the sam ...
分类:
其他好文 时间:
2019-01-10 10:50:58
阅读次数:
114