Can we buy and sell something in the same day?


  • 0
    R

    my question is can an item be the sell of the previous transaction, and at the same time the buy of another one?


  • 1
    L

    you can, it's just like you wasted one chance of transaction. For example, if you bought on Day 1 and sell on Day 5 and bought on Day 5 and sell on Day 10. Profit is P5 - P1 + P10 - P5. It has the same profit as bought on day 1 and sell on day 10(P10 - P1). So it is like that the problem ask you to make at most 2 transactions and you only did one.


  • 0
    V

    It says at most k transaction, so a better thing would be to simply skip that transaction as there can be less than k transactions.


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.