Given a binary tree, return thezigzag level ordertraversal of its nodes' values. (ie, from left to right, then right to left for the next level and al...
分类:
其他好文 时间:
2015-05-21 10:28:55
阅读次数:
159
LeetCode 105:
Given preorder and inorder traversal of a tree, construct the binary tree.
给定一个二叉树的前序和中序遍历,重建这棵二叉树。
LeetCode 106:
Given inorder and postorder traversal of a tree, constru...
分类:
其他好文 时间:
2015-05-21 09:12:32
阅读次数:
207
递归public class Solution { public ArrayList preorderTraversal(TreeNode root) { ArrayList res = new ArrayList(); traversal(root, res); ...
分类:
其他好文 时间:
2015-05-21 07:51:52
阅读次数:
113
http://pages.cs.wisc.edu/~skrentny/cs367-common/readings/Red-Black-Trees/http://en.wikipedia.org/wiki/Red–black_tree1.Every node is either red or blac...
分类:
其他好文 时间:
2015-05-21 07:50:59
阅读次数:
100
Good one to learn Binary Indexed Tree (Fenwick Tree). Simply grabbed the editorial's code but with comments.#include #include #include #include #inclu...
分类:
其他好文 时间:
2015-05-21 07:50:44
阅读次数:
114
Given inorder and postorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.解题思路:给出一个二叉树的中...
分类:
其他好文 时间:
2015-05-21 06:40:31
阅读次数:
121
Given preorder and inorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.解题思路:给出一个二叉树的先序...
分类:
其他好文 时间:
2015-05-21 06:37:42
阅读次数:
96
Given an array where elements are sorted in ascending order, convert it to a height balanced BST.解题思路:用一个有序数组,创建一个平衡二叉查找树。为确保平衡,需要满足两子树的高度差不大于1,可以通过设置...
分类:
其他好文 时间:
2015-05-21 06:37:05
阅读次数:
123
Given a binary tree, flatten it to a linked list in-place.For example,Given 1 / \ 2 5 / \ \ 3 4 6The flattened t...
分类:
其他好文 时间:
2015-05-21 06:36:41
阅读次数:
103
Given a binary tree
struct TreeLinkNode {
TreeLinkNode *left;
TreeLinkNode *right;
TreeLinkNode *next;
}
Populate each next pointer to point to its next right node. ...
分类:
其他好文 时间:
2015-05-21 00:05:17
阅读次数:
181