update: add blog link

This commit is contained in:
ShusenTang 2019-11-05 16:14:39 +08:00
parent de56b16604
commit 6f92b2ca78
2 changed files with 5 additions and 0 deletions

View File

@ -1,4 +1,6 @@
# [121. Best Time to Buy and Sell Stock](https://leetcode.com/problems/best-time-to-buy-and-sell-stock/description/) # [121. Best Time to Buy and Sell Stock](https://leetcode.com/problems/best-time-to-buy-and-sell-stock/description/)
update: LeetCode六道股票买卖题目总结见我的博客文章[动态规划之股票买卖系列](https://shusentang.github.io/2019/11/03/Buy-and-Sell-Stock/)
# 思路 # 思路
题目的意思就是求数组prices中prices[i]-prices[j]的最大值,其中i > j。 题目的意思就是求数组prices中prices[i]-prices[j]的最大值,其中i > j。
因此prices[j]肯定是prices[i]之前的元素中最小的那一个所以从前往后遍历并用min_price记录当前位置前的元素中最小的一个。 因此prices[j]肯定是prices[i]之前的元素中最小的那一个所以从前往后遍历并用min_price记录当前位置前的元素中最小的一个。

View File

@ -1,4 +1,7 @@
# [122. Best Time to Buy and Sell Stock II](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-ii/description/) # [122. Best Time to Buy and Sell Stock II](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-ii/description/)
update: LeetCode六道股票买卖题目总结见我的博客文章[动态规划之股票买卖系列](https://shusentang.github.io/2019/11/03/Buy-and-Sell-Stock/)
# 思路 # 思路
## 比较好想的思路 ## 比较好想的思路
如果分别知道了前0到前i天的最大利润dp[0...i]那么前i+1天的最大利润就为 如果分别知道了前0到前i天的最大利润dp[0...i]那么前i+1天的最大利润就为