Thursday, February 5, 2015

LeetCode [123] Best Time to Buy and Sell Stock III


Note
  • the total profit is the sum of two separate transactions
  • the selling day of the first transaction must be earlier than the buying day of the second transaction
  • if the two transactions are separated by the day i, we need to know
    • 1) the maximum profit of the first transaction if it must be sold by day i, denoted by mp1[i]
    • 2) the maximum profit of the second transaction if it can only be bought from day i+1, denoted by mp2[i+1]
Ref
[1] https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iii/
OJ

No comments:

Post a Comment