Given a binary tree, return thelevel ordertraversal of its nodes' values. (ie, from left to right, level by level).For example:Given binary tree{3,9,2...
分类:
编程语言 时间:
2014-07-12 13:13:24
阅读次数:
195
语言:Python描述:使用递归实现 1 class Solution: 2 # @return an integer 3 def numTrees(self, n): 4 if n == 0: 5 return 0 6 eli...
分类:
其他好文 时间:
2014-07-11 23:44:08
阅读次数:
216
题目:Given preorder and inorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.说明: 1)二叉树可.....
分类:
其他好文 时间:
2014-07-11 21:07:27
阅读次数:
273
apache:方法1: Header set Access-Control-Allow-Origin "*" 方法2:在字体目录下写一个.htaccessHeader set Access-Control-Allow-Origin "*"nginx:location ~*...
分类:
其他好文 时间:
2014-07-09 17:24:19
阅读次数:
231
一个需求: 在域控范围获得访问用户的计算机名.方法:1.测试软件环境: XAMPP Control Panel V3.2.1 , Apache version 2.4.72.Apache 2.2 使用 mod_auth_sspi.so 模块,Apache 2.4 以后此模块不再适用,使用mod_au...
分类:
Web程序 时间:
2014-07-09 16:44:22
阅读次数:
881
NerdTreeThe NERD tree allows you to explore your filesystem and to open files anddirectories. It presents the filesystem to you in the form of a tree ...
分类:
其他好文 时间:
2014-07-09 16:24:53
阅读次数:
193
二叉排序树(Binary Sort Tree):或者是一颗空树,或者是具有以下性质的树:(1)若它的左子树不空,则左子树上所以结点的值均小于它的根节点的值;(2)若它的右子树不空,则右子树上的所以结点的值均大于它的根节点的值;(3)它的左、右子树也分别是二叉排序树。
二叉排序树的基本操作均可以在O(h)时间内完成(算法导论p165)。
相关操作代码如下:
int InsertBST(BiTr...
分类:
其他好文 时间:
2014-07-09 13:12:09
阅读次数:
160
模板
题意:给你一个图,1总是为根,每个边有单位价值,每个点有权重。
每条边的价值 = sum(后继节点权重)*边的单位价值。
求树的最小价值,即构成一棵树的n-1条边的最小价值。
算法:
1、因为每个边的价值都要乘以后来访问的节点的权重,而走到后来访问的点必经过这条边。
实际上总价值就是 到每个点的最短路径*这个点的权重。
2、但是这个题 数据量真的太大了,50000个点...
分类:
其他好文 时间:
2014-07-09 11:33:57
阅读次数:
273
题目
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 ...
分类:
其他好文 时间:
2014-07-09 10:32:42
阅读次数:
151
这个点POJ挂了,代码没法提交,先存到这里,明天再提交试试看。
//#define DEBUG
#include
#define maxn 100002
#define lson l, mid, rt << 1
#define rson mid + 1, r, rt << 1 | 1
__int64 tree[maxn << 2], arr[maxn], lazy[maxn << 2];...
分类:
其他好文 时间:
2014-07-09 09:41:55
阅读次数:
213