Medium
You are given an array prices where prices[i] is the price of a stock on day i. You may buy and sell as many times as you like (but hold at most one share at a time). Return the maximum profit.
Input: prices = [7,1,5,3,6,4] Output: 7
Input: prices = [1,2,3,4,5] Output: 4