Given prices[] and a transaction fee, find the maximum profit from unlimited transactions (each transaction costs fee). You must sell before you buy again.
Two states: hold (holding stock) and cash (not holding). Transition: cash = max(cash, hold + price - fee); hold = max(hold, cash - price).
- Initialize cash=0, hold=-prices[0].
- For each price: new_cash = max(cash, hold + price - fee); new_hold = max(hold, cash - price).
- Return cash.
- Time Complexity: O(N)
- Space Complexity: O(1)