![](https://img-blog.csdnimg.cn/20201014180756923.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
股票
十七十七跳跳糖
这个作者很懒,什么都没留下…
展开
-
714. 买卖股票的最佳时机含【手续费】
714. 买卖股票的最佳时机含手续费题目描述代码链接题目描述代码在每次买入的时候计算手续费即可class Solution { public int maxProfit(int[] prices, int fee) { if(prices == null || prices.length == 0){ return 0; ...原创 2020-03-26 11:15:16 · 60 阅读 · 0 评论 -
309. 最佳买卖股票时机含【冷冻期】
309. 最佳买卖股票时机含冷冻期题目描述思路代码链接题目描述思路代码class Solution { public int maxProfit(int[] prices) { if(prices == null || prices.length == 0){ return 0; } int n = pr...原创 2020-03-26 11:10:52 · 95 阅读 · 0 评论 -
【188】. 买卖股票的最佳时机 IV(最多允许K次交易)
188. 买卖股票的最佳时机 IV题目描述思路链接题目描述思路【通用方法解决股票问题】找到状态转移方程和 base case本题需要注意,k 如果很大会超时如果 K>n/2那就相当于 可以进行无限次交易 public int maxProfit(int k, int[] prices) { if(prices == null || prices.le...原创 2020-03-25 12:05:44 · 269 阅读 · 0 评论 -
【123】. 买卖股票的最佳时机 III(最大允许2次交易)
【123】. 买卖股票的最佳时机 III(最大允许2次交易)题目描述思路【123】. 买卖股票的最佳时机 III(最大允许2次交易)题目描述思路用【通用方法秒杀股票问题】dp[n][k][0~1]: 其中n为天数,k最到目前允许的最大交易次数,0~1表示持有或者不持有找到状态转移方程:dp[i][k][0] = max(dp[i-1][k][0], dp[i-1][k][1] + ...原创 2020-03-25 11:48:02 · 145 阅读 · 0 评论 -
【122】. 买卖股票的最佳时机 II
【122】. 买卖股票的最佳时机 II题目描述思路链接点我题目描述思路 public int maxProfit(int[] prices) { if(prices == null || prices.length == 0){ return 0; } int maxProfit = 0; f...原创 2020-03-25 10:18:26 · 61 阅读 · 0 评论 -
LeetCode-买卖股票的最佳时机121
买卖股票的最佳时机题目描述思路1.暴力法(O(N^2))2.利用最低“谷”,一次遍历O(n)买卖股票的最佳时机121题目描述思路1.暴力法(O(N^2))对每一个值,找后面的最大差值class Solution { public int maxProfit(int[] prices) { //暴力法 if(prices == null || p...原创 2020-01-28 09:41:47 · 95 阅读 · 0 评论