Problem 122: Best Time to Buy and Sell Stock II
https://leetcode.com/problems/best-time-to-buy-and-sell-stock-ii/
思路
允许多次买入卖出,要想利益最大化,我们需要在每一个最低点买入,再在每一个最高点卖出
易错点
数组中有
i + 1
存在的时候,必然考虑到 i 循环到 倒数第二个元素
PreviousProblem 121: Best Time to Buy and Sell StockNextProblem 123: Best Time to Buy and Sell Stock III
Last updated