Problem context and objectives
Matchmaking coordinator · Urgent players and jobs compete for limited slots
Keep the best next candidate available without sorting everything again: The Cooldown Forge.
A stale priority frontier increases wait time for everyone.
How you win
- 1Recognize when Max-heap cooldown scheduling matches the clues
- 2Keep this true after every move: the heap contains every currently eligible task and the queue contains exactly cooling tasks
- 3Reach the result within O(total intervals log distinct tasks)
Rules and pressure
- Target cost: O(total intervals log distinct tasks)
- State rule: the heap contains every currently eligible task and the queue contains exactly cooling tasks
New words in this mission
Open a term for a plain-language explanation.durable queue+
A waiting line that keeps work until a consumer finishes it. It absorbs bursts and lets failed work be retried.
Live algorithm trace
Max-heap cooldown scheduling
Complete executionBuild a max-heap from the two task frequencies; the displayed slots preview the schedule being constructed.
count tasks and build max heaprelease cooled tasks at current timepop the most frequent eligible taskrun it and decrement countqueue it until time + n + 1advance time even when idlereturn elapsed timeTruth to preserve / Cost target
the heap contains every currently eligible task and the queue contains exactly cooling tasks
O(total intervals log distinct tasks)
A max-heap prioritizes the task with the most copies left. Completed tasks wait in a cooldown queue until eligible again; each time unit either runs one task or records an unavoidable idle slot.