121. Best Time to Buy and Sell Stock
# Easy
折线题,minpeak and maxpeak
暴力解题一定会超时
记录maxprofit,和minpeak
很有意义的一道关于折线的基础题
Solution:
if prices[i]<minpeak, 找到了当前最小值
if prices[i] 不是最小值,计算profit,看能否获得最大盈利
Time complexity = , space complexity =
Previous117. Populating Next Right Pointers in Each Node IINext122. Best Time to Buy and Sell Stock II
Last updated