Hard Problemsstocksoptimization

Stock Buy and Sell – At-Most k Times

Given a stock's price on each of n days and a limit of at most k buy-sell transactions, where you never hold more than one share at a time and each sell must follow its matching buy, find the maximum total profit achievable.

Do this lesson first: house robber

The full breakdown and animated table for this problem are still being written. In the meantime, run the four questions on it yourself — that is the whole exercise.