码迷,mamicode.com
首页 >  
搜索关键字:buy tickets    ( 1402个结果
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
uva 10090 Marbles
Problem FMarblesInput:standard inputOutput:standard outputI have some (say,n) marbles (small glass balls) and I am going to buy some boxes to store th...
分类:其他好文   时间:2014-05-26 14:45:04    阅读次数:319
Post These Up-Close Shots Of The Runway Bags
Here are some tips to guide you while shopping discount LV bags online. Look at the rack bag. Before you go out and buy handbags online, it is good to...
分类:其他好文   时间:2014-05-26 10:26:29    阅读次数:279
【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 II
问题:股票交易,交易的次数不限,但是要求在购买新的股票前,必须将旧的股票卖出,即同一时间,最多只能持有一只股票。要求在给定的交易价格序列中,计算出最大的收益。 分析: 保证利润最大,就要求在局部的价格波动中,能在低价买进,高价卖出,也就是说,找个价格走势的递增区间,并且这里可以交易多次,所以可以找到多个价格走势的递增区间,所有区间的收益的和就是最大的利润。 再看下不完全是递增区间的...
分类:其他好文   时间:2014-05-24 19:49:02    阅读次数:349
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
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!