The heart is a bloom #青春 绽放 茂盛 Shoots up through the stony ground #嫩枝 There''s no room No space to rent in this town You''re out of luck And the reaso...
分类:
其他好文 时间:
2014-08-30 09:54:09
阅读次数:
189
给定一个有序数组(递增),写程序构建一棵具有最小高度的二叉树。
由于数组是递增有序的,每次都在中间创建结点,类似二分查找的方法来间最小树。
struct TreeNode
{
int data;
TreeNode* leftChild;
TreeNode* rightChild;
};
void newNode(TreeNode*& vNode, int vData)
{
vNode...
分类:
其他好文 时间:
2014-08-30 02:24:58
阅读次数:
260
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-08-29 22:42:32
阅读次数:
328
题意: 一个树形图,有个二货商人,旅游时候还想着赚钱!从某个地方到另一个地方时,可以旅途中进一批货(应该人手不够,手里只能拿一批),然后在旅途中卖掉,求最大能赚多少钱。思路: 赤裸裸的LCA,ans(x,y)=max(up(x,lca),down(lca,y),maxp(lca,y)-min(l.....
分类:
其他好文 时间:
2014-08-29 22:32:08
阅读次数:
236
本文为senlie原创,转载请保留此地址:http://blog.csdn.net/zhengsenlie
Unique Paths II
Total Accepted: 13655 Total
Submissions: 49081My Submissions
Follow up for "Unique Paths":
Now consider i...
分类:
其他好文 时间:
2014-08-29 16:12:34
阅读次数:
236
Given a linked list, return the node where the cycle begins. If there is no cycle, returnnull.Follow up:Can you solve it without using extra space?题目意...
分类:
其他好文 时间:
2014-08-29 12:44:37
阅读次数:
256
实现一个函数检查一棵树是否平衡。对于这个问题而言, 平衡指的是这棵树任意两个叶子结点到根结点的距离之差不大于1。
这个题我们可以采用暴力搜索,找到叶子节点到根节点的最小值和最大值,然后他们的差如果大于1就不是平衡树,反之
则是平衡树。
int MinDepth = std::numeric_limits::max();
int MaxDepth = std::numeric_limits::...
分类:
其他好文 时间:
2014-08-29 02:52:57
阅读次数:
197
Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?/** * Definition for singly-linked list. *...
分类:
其他好文 时间:
2014-08-28 19:41:25
阅读次数:
224
This is Angela from recruitment team of Amazon Kindle Device Software & Applications, we are expanding and setting up new R&D center in Beijing, we de...
分类:
其他好文 时间:
2014-08-28 19:39:15
阅读次数:
263
按照WPF的帮助说明,某些控件的路由事件被内部处理了,已经被标记为Handled,自行定义的事件处理代码便不再起作用了,有时候会很郁闷! 不过WPF提供了必要的方法。 1)使用相应的Preview事件。须注意隧道类型的事件是从根元素开始执行的。 2)使用AddHandler添加自定义的路...
分类:
其他好文 时间:
2014-08-28 12:52:29
阅读次数:
179