这题真的把递归思想用到极致了。。挺难的。最好能复习一下.要体会它的复杂度是 O(log(n)^2)。 recurs...[作者空间]
这个系列有preorder inorder postorder三题,考点都不是递归,而是迭代。迭代挺难想的,尤其是...[作者空间]
这题是让找一个BST中两个node的Absolute difference,val之差的最小绝对值。 想到BST你...[作者空间]
翻转二叉树。Google的热身题。会写翻转二叉树你就比Max Howell强了。。 我的递归DFS代码: 另一种递...[作者空间]
二叉树的序列化和反序列化。我一开始想用BFS的,但第一不知道怎么处理空子树,第二不知道怎么还原一棵树。于是照着so...[作者空间]
这是leetcode weekly contest31的第二题,easy题。要比较的是「子树」而非「子结构」。树的...[作者空间]
有点感动,这题在AS里写好之后复制过去一次AC了。这种BFS的套路跟这题的第一个版本一样,用queue,维护cur...[作者空间]
Given a binary tree, return the level order traversal of ...[作者空间]
Given a binary tree, determine if it is height-balanced. ...[作者空间]
Given an integer n, generate all structurally unique BST'...[作者空间]
https://leetcode.com/problems/unique-binary-search-trees/...[作者空间]
这题比235题少了个条件,不是搜索树BST了,是普通二叉树。就不能用BST性质做了。还是用递归,但是思维难度大了。...[作者空间]
Given a binary search tree (BST), find the lowest common ...[作者空间]
Given a binary tree, determine if it is a valid binary se...[作者空间]
递归的代码是以前数据结构书上常见的: 非递归用stack模拟中序遍历,要理解啊,不能死记硬背。注意while条件和...[作者空间]
Aug 3 2017 Update 递归方法1: 树只有一个孩子的情况要去递归执行它的孩子,depth要+1。最后...[作者空间]