![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
tree
mars2014jia
这个作者很懒,什么都没留下…
展开
-
Binary Tree Inorder Traversal, Binary Search Tree Iterator
两道题都是inorder traversal, 第二道题目要求如下,可以看出是要in order Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST. Calling next() will return原创 2015-03-07 01:15:05 · 189 阅读 · 0 评论 -
Recover Binary Search Tree
重点 1 inorder 2 怎么用O(1)的space, 必然是用tmp的指针做swap ref http://www.cnblogs.com/springfor/p/3891390.html public class Solution { TreeNode first, pre, second; public void recoverTree(TreeNode root转载 2015-03-21 05:26:26 · 190 阅读 · 0 评论 -
Binary Tree Zigzag Level Order Traversal
1, 注意collections.reverse 指令 2, 注意current level 和next level的识别标记 3, bfs 在这里利用的queue的特性: fifo。 ref :http://www.cnblogs.com/springfor/p/3891393.html /** * Definition for binary tree * publi转载 2015-03-12 00:42:07 · 142 阅读 · 0 评论 -
Construct Binary Tree from Preorder and Inorder Traversal
ref: http://www.cnblogs.com/springfor/p/3884034.html 解释的很详细 public class Solution { public TreeNode buildTree(int[] preorder, int[] inorder) { if(preorder==null|| inorder==null) return nu转载 2015-03-12 04:10:41 · 234 阅读 · 0 评论 -
Construct Binary Tree from Inorder and Postorder Traversal
通类似 Construct Binary Tree from Preorder and Inorder Traversal( ref http://www.cnblogs.com/springfor/p/3884035.htmlpublic class Solution { public TreeNode buildTree(int[] inorder, int[] po转载 2015-03-12 04:33:21 · 229 阅读 · 0 评论