Problem Description:
Given a binary tree, determine if it is a valid binary search tree (BST).
Assume a BST is defined as follows:
The left subtree of a node contains only nodes with keys l...
分类:
其他好文 时间:
2014-05-15 11:22:21
阅读次数:
317
PropertyProvider是取得监控指标的组件,下面给出Resource.Type与PropertyProvider对应关系:
Resource.Type
PropertyProvider
Cluster
GangliaReportPropertyProvider
Service
NagiosProperty...
分类:
其他好文 时间:
2014-05-15 07:22:40
阅读次数:
257
题意:给定一棵perfect binary tree,将它每一个节点的next指针都指向该节点右边的节点
思路:dfs
在connect一棵树的时候,需要知道这棵树的根节点和它右边的节点
1.将树的根节点和它右边的节点连接起来
2.递归地将左子树connect起来,需要知道左子树节点和右子树节点
3.递归地将右子树connect起来,需要知道右子树节点和根右边的节点的左子树节点
递归函数为:
void connect(TreeLinkNode *root, TreeLinkNode *sibling)
表...
分类:
其他好文 时间:
2014-05-15 07:14:04
阅读次数:
289
题意:给定一棵任意二叉树(不一定是perfect binary tree),将它每一个节点的next指针都指向该节点右边的节点
思路:bfs
这里不能用dfs了,只能用bfs
bfs遍历将同一层的节点存放在同一个数组里,
然后在遍历每个数组,将前面的节点和后面的节点connect起来,
最后一个节点和NULL connect起来
需要定义一个新的struct结构,保存指向每个节点的指针和该节点所在的层
复杂度:时间O(n), 空间O( n)...
分类:
其他好文 时间:
2014-05-15 06:12:13
阅读次数:
294
1、
??
Populating Next Right Pointers in Each Node
Given a binary tree
struct TreeLinkNode {
TreeLinkNode *left;
TreeLinkNode *right;
TreeLinkNode *next;
}
Populate...
分类:
其他好文 时间:
2014-05-15 04:57:36
阅读次数:
221
LeetCode-001 Two Sum
Given an array of integers, find two numbers such that they add up to a specific target number.
The function twoSum should return indices of the two numbers such that they add up to the target, where index1 must be less than index2...
分类:
其他好文 时间:
2014-05-15 04:34:50
阅读次数:
293
题目来源:UVa 10308 Roads in the North
题意:求距离最远的2点之间的距离
思路:裸的树的直径 或者树形DP
#include
#include
#include
using namespace std;
const int maxn = 100010;
struct node
{
int to, w;
node(){}
node(int to, int...
分类:
其他好文 时间:
2014-05-15 03:37:18
阅读次数:
295
题意:移除链表的倒数第n个元素
思路:
两个指针p, q,
p先走n步,然后p,q一起走,当p走到尾的时候,q->next就是要删除的节点
复杂度: 时间O(n),空间O(1)...
分类:
其他好文 时间:
2014-05-15 02:53:13
阅读次数:
241
这篇文章提出了backgroundjs这个新的概念,扩展了Node.js的能力,解决了Node在处理CPU密集任务时的短板。这个解决方案使得使用Node的开发人员只需要关注backgroundjs中的函数。比起多开进程或者新添加模块的解决方案更高效,通用和一致。...
分类:
Web程序 时间:
2014-05-14 21:16:18
阅读次数:
502
node.js API 英文原版
http://nodejs.org/api/all.html
node.js API 中文翻译
http://nodeapi.ucdok.com/#/api/
node.js API 中文翻译下载
http://download.csdn.net/detail/bad19876414641/4608699
javascrip...
分类:
Web程序 时间:
2014-05-14 15:15:10
阅读次数:
329