题意: 一个树形图,有个二货商人,旅游时候还想着赚钱!从某个地方到另一个地方时,可以旅途中进一批货(应该人手不够,手里只能拿一批),然后在旅途中卖掉,求最大能赚多少钱。思路: 赤裸裸的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
写程序将一个栈按升序排序。对这个栈是如何实现的,你不应该做任何特殊的假设。
程序中能用到的栈操作有:push | pop |isEmpty
最容易想到的就是优先队列来做此题,容易实现。
另外我们可以再用一个栈来实现栈的升序排列。
优先队列:
//优先队列来实现
void sortStack(std::stack& vStk)
{
std::priority_queue, std::gr...
分类:
其他好文 时间:
2014-08-28 02:07:58
阅读次数:
197
17.You configure AUTOBACKUP to ON in an RMAN session. When will RMAN back up the control file?
(Choose all that apply.)
A. When you run an RMAN BACKUP command
B. When you run an RMAN ALLOCATE comma...
分类:
其他好文 时间:
2014-08-28 00:53:58
阅读次数:
189