Reported July 2025
Googleheap priority queue

Priority Job Scheduler with Cooldowns

Reported by candidates from Google's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Google OA. Under 2s to a working solution.
Founder's read

Google reported this one in July 2025, and the detail that trips people is the cooldown rule: a job with cooldown 3 needs three GET calls in between, and a GET that returns NONE still counts. It's a simulation with two heaps, or a heap plus a time-indexed queue. If you've got an OA invite, expect to write ADD and GET handling for up to 100000 operations without a linear scan per GET. StealthCoder sits invisibly on your screen as a safety net if you blank on the cooldown bookkeeping mid-assessment.

The problem

Simulate a scheduler over the finite sequence in operations. Each operation is one of:
ADD id priority cooldown: register one persistent job with a unique lowercase identifier, integer priority, and nonnegative cooldown.
GET: return the eligible job with the greatest priority. If several eligible jobs have the same priority, return the lexicographically smallest identifier. If no job is eligible, return NONE.
Only GET operations advance scheduler time. A newly added job is eligible immediately. After a job is returned by a GET, it remains registered but is ineligible for its next cooldown intervening GET operations. For example, if a job with cooldown 3 is returned on one call, three later GET calls must occur before it can be returned again. A GET that returns NONE still counts as an intervening call.
Return the result of every GET operation in order.

Function
runPriorityScheduler(operations: String[]) → String[]

Examples
Example 1
operations = ["ADD A 10 3","ADD B 5 0","GET","GET","GET","GET","GET"]
return = ["A","B","B","B","A"]
Job A wins the first call by priority. Its cooldown requires calls two, three, and four to intervene, so A becomes eligible again on call five. Job B has cooldown 0 and fills the intervening calls.
Example 2
operations = ["GET","ADD beta 7 1","ADD alpha 7 2","GET","GET","GET","GET"]
return = ["NONE","alpha","beta","NONE","alpha"]
The first call has no registered jobs. On the next call, alpha wins the priority tie lexicographically. It needs two intervening calls, while beta needs one after being selected. Both are cooling on the fourth overall GET, and alpha returns on the fifth.

Constraints
1 <= operations.length <= 100000
Every operation is exactly GET or has the form ADD id priority cooldown.
Each identifier contains 1 through 20 lowercase English letters and is added exactly once.
0 <= priority <= 10^9
0 <= cooldown <= operations.length

Reported by candidates. Source: FastPrep

Pattern and pitfall

Keep a GET counter t. Maintain a max-heap of eligible jobs keyed by (priority descending, id ascending). Keep a cooldown structure, a map from call number to a list of jobs that wake up then, or a min-heap keyed by wake time. On each GET, increment t, first move jobs whose wake time is at most t into the eligible heap, then pop the best one. If the heap is empty, output NONE. When you pop job j at call t with cooldown c, it becomes eligible again at call t + c + 1. Check that against Example 1: A at call 1 with cooldown 3 returns at call 5. The pitfall is off-by-one on that wake time, and forgetting that NONE still advances time. Also ADD must push straight into the eligible heap, since new jobs are eligible immediately. Each job enters and leaves heaps once per selection, so total work is O(n log n). StealthCoder is the hedge if the heap ordering or wake-time math slips under pressure.

If this hits your live OA and you blank, StealthCoder solves it in seconds, invisible to the proctor.

If this hits your live OA

You can drill Priority Job Scheduler with Cooldowns cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it.

Get StealthCoder

Related leaked OAs

⏵ The honest play

You've seen the question. Make sure you actually pass Google's OA.

Google reuses patterns across OAs. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Priority Job Scheduler with Cooldowns FAQ

What's the trick in the Priority Job Scheduler problem?+

Use two structures. A max-heap holds eligible jobs ordered by priority, then lexicographic id. A wake-up store holds cooling jobs by the GET number when they return. Each GET releases due jobs, then pops the top. That avoids scanning every job per call.

What's the correct wake-up time after a job is returned?+

If a job is returned on GET number t with cooldown c, it can be returned again on GET number t + c + 1. Cooldown counts intervening GETs, so c calls must happen between. Example 1 confirms it: A at call 1 with cooldown 3 returns at call 5.

Does a GET that returns NONE advance time?+

Yes. The statement says a NONE result still counts as an intervening call. Increment your GET counter every time, before checking the heap. Example 2 depends on this, since the fourth GET returns NONE and moves alpha closer to its return on the fifth.

How hard is this really for a Google OA?+

Medium. The idea is a standard heap simulation, but the details are easy to get wrong: tie-breaking by smallest id, the wake-time off-by-one, and ADD jobs being eligible immediately. With 100000 operations, a brute-force scan per GET risks being too slow.

How do I prepare in 48 hours?+

Write this once from scratch. Code the heap with a tuple key like (-priority, id), add a wake-time map, and trace both examples by hand. Then test edge cases: cooldown 0, GET before any ADD, and several jobs with equal priority.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Google.

OA at Google?
Invisible during screen share
Get it