此题应用线段树的方法非常巧妙。没做过真的难想得出是这么想的。
是一个逆向思维的运用。
其实一看到这道题目我就想到要运用逆向思维的了,但是就是没那么容易想通的。
思路:
1 要从后面往前更新线段树
2 线段树记录的是当前区间还剩下多少个记录空间
3 因为后面的插入会使得前面的插入往后退,那么前面插入的下标如果大于前面可以插入的空间,就需要往后退了。
好难理解的操作。仔细观察一下下面up...
分类:
其他好文 时间:
2014-06-19 12:54:26
阅读次数:
248
Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complet...
分类:
其他好文 时间:
2014-06-17 14:57:30
阅读次数:
269
They can usually be purchased in three sizes: £
5, £ 1 and a half pound bags. I even saw them to buy on eBay. Many companies are
cutting Tekpak bag of...
分类:
其他好文 时间:
2014-06-16 09:23:39
阅读次数:
443
Say you have an array for which theithelement
is the price of a given stock on dayi.If you were only permitted to complete at
most one transaction (ie...
分类:
其他好文 时间:
2014-06-13 15:55:47
阅读次数:
273
Question:Say you have an array for which
theithelement is the price of a given stock on dayi.Design an algorithm to find
the maximum profit. You may c...
分类:
其他好文 时间:
2014-06-12 19:55:05
阅读次数:
292
整个金融行业大致分为buy side和sell side两大类。Sell
side做的主要是把各种asset变成各种金融产品,提供给市场。Sell side主要指的是通常意义上的投行。投行内部结构也很复杂,按照产品分大致分为fixed
income和equity两大类。按照业务分大致分为IBD, s...
分类:
其他好文 时间:
2014-06-09 22:49:39
阅读次数:
254
Now, when you buy food, you will be able to
return home in reusable bags that will not be rejected, which can be used over
and over again, and washed ...
分类:
其他好文 时间:
2014-06-09 18:35:51
阅读次数:
320
原创地址:http://www.cnblogs.com/Alandre/(泥沙砖瓦浆木匠),需要转载的,保留下! ThanksTalk is cheap.
Show me the code.Written In The Font 图能抵过一切,喜欢咖啡喜欢java.Con...
分类:
编程语言 时间:
2014-06-08 21:11:54
阅读次数:
310
【题目】
Say you have an array for which the ith element is the price of a given stock on day i.
If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock), design an algorithm to find the maximum profit.
...
分类:
其他好文 时间:
2014-06-08 15:11:58
阅读次数:
298