← ALL NOTES
Array

122. Best Time to Buy and Sell Stock II

With unlimited transactions, greedily capture every up-day: sum all the positive daily gains, prices[i] − prices[i-1] whenever it's positive. It's optimal because any multi-day rise decomposes into…

Loading…