Problem 188 · Hard

Best Time to Buy and Sell Stock IV

Generalize two-transaction DP to k transactions, collapsing to O(n) when k exceeds n/2.

Open the interactive visualisation