Problem context and objectives
Mission briefing
Live-ops game engineer · A multiplayer arena is reporting bursts of lag
Find the smallest or strongest contiguous time window: The Budget Corridor.
Scanning the entire history after every event cannot keep up with live players.
How you win
- 1Recognize when Longest valid window matches the clues
- 2Keep this true after every move: the current window sum never exceeds the limit after contraction
- 3Reach the result within O(n)
Rules and pressure
- Target cost: O(n)
- State rule: the current window sum never exceeds the limit after contraction
Lesson 1 of 3
Every right step adds one cost. If the limit breaks, move left only as far as needed to restore validity.
Your call · Cost is 7 with limit 5. When do we measure length?