Given a binary tree, find the maximum path sum.
The path may start and end at any node in the tree.
For example:
Given the below binary tree,
1
/ \...
分类:
其他好文 时间:
2015-02-14 15:02:11
阅读次数:
198
Given preorder and inorder traversal of a tree, construct the binary tree.
Note:
You may assume that duplicates do not exist in the tree.
这道题要求根据二叉树的前序遍历序列和中序遍历序列构建二叉树。
举个例子:
前序序列:A B D E F C...
分类:
其他好文 时间:
2015-02-14 13:48:00
阅读次数:
145
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-02-14 13:47:49
阅读次数:
216
gb_tree, gb_set, 均为一个二叉树。具体怎么实现,这边不在累赘,官方有手册,how to use ? 才是我们的重点1. 初始化1> gb_trees:empty().{0,nil}> gb_sets:empty().{0,nil}3> 这样即可完成初始化2. 插入gb_trees:i...
分类:
其他好文 时间:
2015-02-14 12:13:34
阅读次数:
320
http://poj.org/problem?id=1655
Description
Consider a tree T with N (1 <= N <= 20,000) nodes numbered 1...N. Deleting any node from the tree yields a forest: a collection of one or more trees. D...
分类:
其他好文 时间:
2015-02-14 08:43:14
阅读次数:
216
维护一个带点权的无向图森林,支持: 1、删边 2、加边 3、增加某条链所有点的点权 4、求某条链上点权的最大值大概思路:前两个需要更改根(即需要翻转标记)第三个又需要一个标记,第四个每个节点记录该splay中以该节点为根的子树的最大点权。收获: 1、对于splay前的标记下传可用递归写法,...
分类:
其他好文 时间:
2015-02-13 23:38:15
阅读次数:
192
Given a binary tree, find its maximum depth.
The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.
这道题是求一个二叉树的深度。题目中对深度的定义是:从根节点到叶节点依次经...
分类:
其他好文 时间:
2015-02-13 21:15:47
阅读次数:
156
Given a binary tree, return the bottom-up level order traversal of its nodes’ values. (ie, from left to right, level by level from leaf to root).
For example:
Given binary tree {3,9,20,#...
分类:
其他好文 时间:
2015-02-13 21:12:18
阅读次数:
136
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,9,20,#,#,15,7},
3...
分类:
其他好文 时间:
2015-02-13 20:01:56
阅读次数:
136
Given a binary tree, return the zigzag level order traversal of its nodes’ values. (ie, from left to right, then right to left for the next level and alternate between).
For example:
Giv...
分类:
其他好文 时间:
2015-02-13 19:59:21
阅读次数:
198