Took me an embarrassingly long time to realize the streak bonus structure is what makes this non-trivial.
Model the problem as maximizing earnings over n days with at most k flips from off to work, where each workday gives a fixed wage and each adjacent pair of workdays gives a streak bonus. Use dynamic programming with states (day index, flips used, whether previous day was worked) to compute the optimal earnings, then optimize to O(nk) time and O(k) space. Discuss trade-offs between DP and greedy approaches, noting that greedy fails due to the interaction between flips and streak bonuses.
Pro tip: Emphasize that the streak bonus makes this a weighted interval scheduling variant, and mention that you can reduce space by keeping only the previous day's DP states. Also, clarify that flips are only from off to work, not vice versa, and that you can flip at most k days.
Restate the problem: given a binary schedule of n days (1=work, 0=off), a fixed wage W per workday, a streak bonus B for each pair of consecutive workdays, and at most k flips from 0 to 1, maximize total earnings. Confirm that flips are only 0→1 and that you can flip at most k days.
Let dp[i][j][s] be the max earnings for the first i days using exactly j flips, where s=1 if day i is worked (after flips) and s=0 otherwise. Recurrence: if day i is off, dp[i][j][0] = max(dp[i-1][j][0], dp[i-1][j][1]); if day i is worked, dp[i][j][1] = W + max(dp[i-1][j][0], dp[i-1][j][1] + B) plus flip cost if original day was off.
Observe that dp[i] depends only on dp[i-1], so reduce space to O(k) by keeping two arrays for s=0 and s=1. Time complexity is O(nk). Mention that if k is large, you can cap k at the number of off days.
Initialize dp[0][0][0]=0, dp[0][0][1]=-inf, and for j>0, dp[0][j][*]=-inf. At the end, answer is max over j≤k and s of dp[n][j][s]. Consider cases where n=0, k=0, or all days already worked.
Mention that a greedy approach (e.g., flipping days that create the most streaks) may fail because flips interact. Compare with a min-cost max-flow formulation or a DP with state compression. Highlight that DP is optimal and efficient for typical constraints.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.