Z04
Stock Trading with Cooldown
Problem Statement & Objective
Find maximum profit from stock trading with a mandatory one-day cooldown after each sale.
Function Signature (Python)
stock_trading_with_cooldown(prices: list[int], fee: int) -> intInput & Output Contract
Output Rule:Negatif olmayan tam sayı (zarar eden işlem yapılmaz). Boş liste için 0.
System Constraints
0 <= fiyatlar.length <= 10^5
0 <= fiyatlar[i] <= 10^4
0 <= islem_ucreti <= 10^4Example Execution Walkthrough
fiyatlar = [1, 2, 3, 0, 2], islem_ucreti = 0
en iyi strateji: 1. gün al (1) -> 2. gün sat (2) -> 3. gün bekle -> 4. gün al (0) -> 5. gün sat (2)
kâr = (2-1) + (2-0) = 3
cevap: 3Example Test Scenarios (3)
Example 1
Input:
[[1,2,3,0,2],0]Expected Output:
3Example 2: İşlem Ücreti 3
Input:
[[1,3,7,5,10,3],3]Expected Output:
6Example 3: Sıfır Ücret Monoton Artan
Input:
[[1,2,3,4],0]Expected Output:
3