Hard Problemsstocksoptimization

Stock Buy and Sell – At Most 2 Times

Given a stock's price on each of n days and a limit of at most two 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.