上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 45 下一页
摘要: 188. 买卖股票的最佳时机 IV 解释见代码: class Solution { public: int maxProfit(int k, vector<int>& prices) { if(prices.size()==0||k==0) return 0; if(k>=prices.size() 阅读全文
posted @ 2020-06-04 21:57 branna 阅读(176) 评论(0) 推荐(0) 编辑
摘要: 123. 买卖股票的最佳时机 III 1. 解释见如下代码: class Solution { public: int maxProfit(vector<int>& prices) { if(prices.size()==0)//容易忘的点 return 0; int dp[prices.size( 阅读全文
posted @ 2020-06-04 00:10 branna 阅读(200) 评论(0) 推荐(0) 编辑
摘要: 122. 买卖股票的最佳时机 II 解释见代码 class Solution { public: int maxProfit(vector<int>& prices) { int dp[prices.size()+100][2]; dp[0][0]=0;//第一天没买的利润为0 dp[0][1]=- 阅读全文
posted @ 2020-06-03 12:26 branna 阅读(195) 评论(0) 推荐(0) 编辑
摘要: 121. 买卖股票的最佳时机 class Solution { public: int maxProfit(vector<int>& prices) { int less=2e5+100; int ans=0; for(int i=0;i<prices.size();i++) { less=min( 阅读全文
posted @ 2020-06-02 22:25 branna 阅读(214) 评论(0) 推荐(0) 编辑
摘要: 714. 买卖股票的最佳时机含手续费 dp[i][0]表示手上没有股票,一个是之前没有股票,一个是之前有股票然后卖掉了 dp[i][1]表示手上有股票,一个是之前有股票,一个是之前没有股票,然后买了 class Solution { public: int maxProfit(vector<int> 阅读全文
posted @ 2020-06-02 21:47 branna 阅读(174) 评论(0) 推荐(0) 编辑
上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 45 下一页