码迷,mamicode.com
首页 >  
搜索关键字:sell stock iv    ( 3393个结果
【leetcode】Best Time to Buy and Sell Stock III
题目:这个题目里要求最多交易2次。也就是说可以只交易一次,不交易也可以。 分析:将整个交易序列分割成两部分,求出这样的一种分割,使得两部分连续子序列的和相加的结果最大,当然,如果不进行分割,就是求出整个序列的最大连续子序列的和。 那么分割点就可能是任意位置。找出取得最大值的分割点,返回最大值。 int maxProfit(vector &prices) { const int le...
分类:其他好文   时间:2014-05-24 20:54:57    阅读次数:402
LeetCode Best Time to Buy and Sell Stock
class Solution {public: int maxProfit(vector &prices) { int len = prices.size(); if (len maxv) { maxv = cur; ...
分类:其他好文   时间:2014-05-22 05:09:49    阅读次数:256
Best Time to Buy and Sell Stock III
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 complete a...
分类:其他好文   时间:2014-05-21 17:27:55    阅读次数:252
leetcode Best Time to Buy and Sell Stock III
思路:知道要用DP做,但是一开始思路是错的。后来参考了http://blog.csdn.net/pickless/article/details/12034365才意识到可以在整个区间的每一点切开,然后分别计算左子区间和右子区间的最大值,然后再用O(n)时间找到整个区间的最大值。看来以后碰到与2相关...
分类:其他好文   时间:2014-05-19 14:13:38    阅读次数:286
【leetcode】Best Time to Buy and Sell Stock
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-05-18 20:30:16    阅读次数:301
Android小应用-----画画板
public class MainActivity extends Activity { private ImageView iv; float startX = 0; float startY = 0; //获得一个可以被bitmap Bitmap bitmap = Bitmap.createBitmap(400, 400,Bitmap.Config.ARGB_8888); //创...
分类:移动开发   时间:2014-05-18 15:54:33    阅读次数:318
SPOJ GSS4 Can you answer these queries IV (线段树)
题目大意: 给出N个数   0     操作   把 l -----  r之间的数全部开平方 1     操作  输出 l -----r  之间的和 思路分析: 判断区间里的数字是否全相同。如果相同, 将cov 置为该数 查询的时候和更新的时候,如果碰到cov != -1 的  就直接返回就可以了 #include #include #include...
分类:其他好文   时间:2014-05-18 05:25:06    阅读次数:227
ZOJ3629 Treasure Hunt IV(找规律,推公式)
Treasure Hunt IV Time Limit: 2 Seconds      Memory Limit: 65536 KB Alice is exploring the wonderland, suddenly she fell into a hole, when she woke up, she found there are b - a + 1 treasures...
分类:其他好文   时间:2014-05-18 04:09:03    阅读次数:248
linux下的shell命令的编写,以及java如何调用linux的shell命令(java如何获取linux上的网卡的ip信息)
最近在开发中,需要用到服务器的ip和mac信息。但是服务器是架设在linux系统上的,对于多网口,在获取ip时就产生了很大的问题。下面是在windows系统上,java获取本地ip的方法。 在Linux系统中,虽然有各种各样的图形化接口工具,但是sell仍然是一个非常灵活的工具。Shell不仅仅是命令的收集,而且是一门非常棒的编程语言。您可以通过使用shell使大量的任务自动化,shell特别擅长系统管理任务,尤其适合那些易用性、可维护性和便携性比效率更重要的任务。 hello world 让我们一起学习l...
分类:编程语言   时间:2014-05-18 03:33:23    阅读次数:345
Best Time to Buy and Sell Stock I && II && III
题目1:Best Time to Buy and Sell Stock 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,...
分类:其他好文   时间:2014-05-16 01:46:15    阅读次数:460
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!