A proprietary trading strategy at HRT trades a single equity contract across continuous trading days. You are given an array of daily stock prices prices and a flat transaction fee fee charged on every sale transaction.
Trading Rules:
fee is deducted from net proceeds on the day of the sale.Your Task
Implement max_profit_with_fee_and_cooldown(prices: list[int], fee: int) -> int that determines the maximum cumulative net profit achievable.
Constraints
Examples
prices = [1, 2, 3, 0, 2]
fee = 1
# Day 0: Buy @ 1
# Day 2: Sell @ 3 (profit = 3 - 1 - fee(1) = 1)
# Day 3: Cooldown (cannot buy)
# Day 4: Buy @ 2, sell same day or hold -> profit 1
# Output: 1
prices = [1, 3, 7, 5, 10, 3]
fee = 2
# Buy @ 1, sell @ 7 -> profit 7 - 1 - 2 = 4
# Day after sale is cooldown.
# Buy @ 5, sell @ 10 -> profit 10 - 5 - 2 = 3
# Total profit = 4 + 3 = 7
# Output: 7