Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.
For example:
Given the below binary tree and sum...
分类:
其他好文 时间:
2014-06-22 20:59:24
阅读次数:
227
Given a binary tree, return the postorder traversal of its nodes' values.
For example:
Given binary tree {1,#,2,3},
1
2
/
3
return [3,2,1].
Note: Recursive solut...
分类:
其他好文 时间:
2014-06-22 20:58:01
阅读次数:
157
使用线段树预处理,可以使得查询RMQ时间效率在O(lgn)。
线段树是记录某范围内的最小值。
标准的线段树应用。
Geeks上只有两道线段树的题目了,而且没有讲到pushUp和pushDown操作,只是线段树的入门了。
参考:http://www.geeksforgeeks.org/segment-tree-set-1-range-minimum-query/
我修改了一下他的程序,使用...
分类:
其他好文 时间:
2014-06-22 18:08:05
阅读次数:
217
Beavergnaw
Time Limit: 1000MS
Memory Limit: 65536K
Total Submissions: 6204
Accepted: 4090
Description
When chomping a tree the beaver cuts a very specific shape out o...
分类:
其他好文 时间:
2014-06-22 17:06:55
阅读次数:
233
平时使用过两种版本控制软件 SVN 和 Git,平心而论,如果纯粹自己使用,那么绝对 Git 更加适合,本地库、远程库、离线工作、强大而灵活的分支、大名鼎鼎的Github, 这些都是选择 Git 的原因。Git 本质上是一套内容寻址文件系统。
从内部来看,Git 是简单的 key-value 数据存储。Git主要包含 3 类对象:blog(对应文件)、tree(对应目录)、commit。每次 Git 提交都会产生一个 commit 对象,并更新有改动的文件所关联的所有 tree 对象。多个 tree 对象一...
分类:
其他好文 时间:
2014-06-22 16:53:50
阅读次数:
166
Given a binary tree, return the preorder traversal of its nodes' values.
For example:
Given binary tree {1,#,2,3},
1
2
/
3
return [1,2,3].
Note: Recursive soluti...
分类:
其他好文 时间:
2014-06-22 16:37:51
阅读次数:
168
题目描述在图论中,包含n个结点(结点编号为1~n)、n-1条边的无向连通图被称为树。 在树中,任意一对结点间的简单路径总是惟一的。 你拥有一棵白色的树——所有节点都是白色的。接下来,你需要处理c条指令: 修改指令(0 v):改变一个给定结点的颜色(白变黑,黑变白); 查询指令(1 v):询问从结点1...
分类:
其他好文 时间:
2014-06-22 12:55:54
阅读次数:
213
Convert Sorted List to Binary Search Tree
Total Accepted: 12283 Total
Submissions: 45910My Submissions
Given a singly linked list where elements are sorted in ascending order, convert it...
分类:
其他好文 时间:
2014-06-21 23:57:00
阅读次数:
351
Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.
For example:
Given the below binary tree and sum = 22,
5
/ ...
分类:
其他好文 时间:
2014-06-21 22:44:58
阅读次数:
266
这道题也有点新意,就是需要记录最小值段和最大值段,然后成段更新这个段,而不用没点去更新,达到提高速度的目的。
本题过的人很少,因为大部分都超时了,我严格按照线段树的方法去写,一开始居然也超时。
然后修补了两个地方就过了,具体修改的地方请参看程序。
知道最大值段和最小值段,然后修补一下就能过了。不是特别难的题目。
#include
#include
#include
using na...
分类:
其他好文 时间:
2014-06-21 20:14:04
阅读次数:
230