Given an integer array stock_prices where stock_prices[i] represents the price of a stock on day i, compute the maximum possible profit by buying and selling the stock any number of times. You may buy and sell on the same day, but you can only hold at most one share at any time. Return the maximum profit achievable.
Example 1
Input: [2, 4, 1, 7, 5]
Output: 8
Explanation: Buy at 2, sell at 4 (profit 2). Buy at 1, sell at 7 (profit 6). Total profit: 2+6=8.
Example 2
Input: [3, 3, 3, 3]
Output: 0
Explanation: No price increase, so no profit.
Example 3
Input: [1, 5, 2, 8]
Output: 10
Explanation: Buy at 1, sell at 5 (profit 4). Buy at 2, sell at 8 (profit 6). Total profit: 4+6=10.
Constraints
Case 1
Input: [10, 12, 11, 15, 13, 18]
Expected: 11
Case 2
Input: [5, 4, 3, 2, 1]
Expected: 0
Case 3
Input: [1, 2, 1, 2, 1, 2]
Expected: 3