There are a classical interview problem of maximizing profit, buying stocks with one transaction, n transactions and k transactions allowed.
I was asked a similar problem but with a twist constraint: You may buy a stock any number of times(no more than one unit on any day), but you cannot buy after you've sold the stock.
This has a lemma that you sell only once.
eg: 70 40 90 110 80 100
Option 1 : B B B Sell _ _ = 130
Option 2 : B B B X B Sell = 120
Older problems
https://www.geeksforgeeks.org/stock-buy-sell/
https://www.geeksforgeeks.org/maximum-profit-by-buying-and-selling-a-share-at-most-twice/
https://www.geeksforgeeks.org/maximum-profit-by-buying-and-selling-a-share-at-most-k-times/
Stackoverflow discussions
maximizing profit for given stock data via DP
Maximizing profit for given stock quotes
Maximum profit by buying and selling a share exactly k times