Given an array of daily stock prices, find the maximum profit achievable by completing as many non-overlapping buy-sell transactions as you like.
Example 1
Explanation: Buy at 1, sell at 5 (profit 4); buy at 3, sell at 6 (profit 3). Total profit = 4 + 3 = 7.
Example 2
Explanation: Buy at 1, sell at 5 in one continuous climb — equivalent to summing every day-to-day gain: 1+1+1+1 = 4.
Example 3
Explanation: Prices only fall, so no transaction is ever profitable.
What changes if a fixed transaction fee is charged on every sale?
Code execution is coming soon.