# 123 Best Time to Buy and Sell Stock III

input是一個array裡面存某股票每天的價格, 算出在兩次transaction內可以獲得的最高利潤。

  • Idea:

    test case:
    [7,1,4,3,6,5,8]
    (1,4) -> 3
    (3,8) -> 5
    total -> 8
    
    keep four variables:
    firstBuy
    firstSell
    secondBuy
    secondSell
    
    if()
    

results matching ""

    No results matching ""