122-best-time-to-buy-and-sell-stock-ii
买卖股票最佳时机II
思路
这题思路是先找股票如果遇到更便宜的话吧最小值给他,遇到比最小值大的值在与最小值相见在取和最大的利润相比,如果今天的股票价格大于昨天的股票价格直接取前面最大利润的那次
go阶梯代码
1 | func maxProfit(prices []int) int { |
<++>
All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.
Comment