码迷,mamicode.com
首页 >  
搜索关键字:best    ( 2208个结果
LeetCode123:Best Time to Buy and Sell Stock III
题目: 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 co...
分类:其他好文   时间:2014-05-28 22:37:18    阅读次数:327
【百度之星2014~初赛解题报告】
最近要毕业了,有半年没做比赛了.这次参加百度之星的初赛娱乐一下.现在写一下解题报告.还是先看看四道题的类型吧1.Scenic Popularity 暴力 复杂度O( 100 * 100 * 10000 ) 或者O( T * K * R) 线段树2.Chess DP 复杂度 O(n^2)3.Best ...
分类:其他好文   时间:2014-05-28 13:19:16    阅读次数:261
LeedCode --- Best Time to Buy and Sell Stock
题目链接题意: find the maximum positive difference between the price on the ith day and the jth day附上代码: 1 class Solution { 2 public: 3 int maxProfit(ve...
分类:其他好文   时间:2014-05-28 03:49:45    阅读次数:307
[leetcode]_Best Time to Buy and Sell Stock I && II
一个系列三道题,我都不会做,google之答案。过了两道,第三道看不懂,放置,稍后继续。一、Best Time to Buy and Sell Stock I题目:一个数组表示一支股票的价格变换。要求只买卖一次,获得最大收益。思路:一开始我认为是寻找最大、最小值,但由于最大值不一定总是出现在最小值的...
分类:其他好文   时间:2014-05-28 01:21:52    阅读次数:262
LeetCode121: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 transac...
分类:其他好文   时间:2014-05-28 00:55:20    阅读次数:288
LeetCode122:Best Time to Buy and Sell Stock II
题目: 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 co...
分类:其他好文   时间:2014-05-28 00:53:26    阅读次数:338
HDU 4833 Best Financing DP
Best FinancingTime Limit: 20000/10000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 120Accepted Submission(s): 24Probl...
分类:其他好文   时间:2014-05-27 17:52:10    阅读次数:223
POJ 1699 Best Sequence(DFS)
題目鏈接題意 : 將幾個片段如圖所示方法縮成一個序列,求出最短這個序列。思路 : 其實我也不知道怎麼做。。。。。看網上都用了DP。。。。。但是我不會。。。。。這個DP不錯,還有用KMP+状压DP做的 1 //1699 2 #include 3 #include 4 #include 5 #in...
分类:其他好文   时间:2014-05-27 16:06:19    阅读次数:282
HDU 4833 Best Financing (DP)
Best FinancingTime Limit: 20000/10000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 29Accepted Submission(s): 3Problem...
分类:其他好文   时间:2014-05-25 20:13:10    阅读次数:211
【leetcode】Best Time to Buy and Sell Stock II
问题:股票交易,交易的次数不限,但是要求在购买新的股票前,必须将旧的股票卖出,即同一时间,最多只能持有一只股票。要求在给定的交易价格序列中,计算出最大的收益。 分析: 保证利润最大,就要求在局部的价格波动中,能在低价买进,高价卖出,也就是说,找个价格走势的递增区间,并且这里可以交易多次,所以可以找到多个价格走势的递增区间,所有区间的收益的和就是最大的利润。 再看下不完全是递增区间的...
分类:其他好文   时间:2014-05-24 19:49:02    阅读次数:349
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!