Now you can make as many transactions as you want.
You can buy and sell on the same day, but you cannot hold multiple shares. For , the maximum profit is : buy at , sell at (profit ), buy at , sell at (profit ).
With unlimited transactions, the greedy approach changes.
Think about when it makes sense to "buy" and when to "sell." Every upward price movement is profit.