Code RoomFind worst job overlap
HardPrep Room Coding #4942

Find worst job overlap

CodingAlgorithms & data structuresMid–Staff~35 min

A CI fleet must run every job today. Job i cannot begin before releases[i], must be finished by deadlines[i], and once begun it runs without interruption for runtimes[i] minutes. The scheduler places each job anywhere inside its own span, and the jobs know nothing about each other. Some minutes are unavoidable: whatever the scheduler picks, a job whose span leaves it little slack has to be running then. Capacity planning wants the worst such moment, so return the largest number of jobs that are certainly running together at one single minute under every possible placement. Return 0 when no minute is forced on anybody. Return -1 when some job cannot fit inside its own span at all. Minute stamps may be negative, they reach 10^9 in size, and there can be 100000 jobs.

Implement
guaranteed_concurrency(releases: list[int], deadlines: list[int], runtimes: list[int]) → int
Examples
in[[0,0],[10,10],[8,8]]out2
in[[0],[100],[10]]out0
in[[5],[8],[4]]out-1
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

0:00 of about 35 min
InputExpectedGot
[[0,0],[10,10],[8,8]]2not run yetsample
[[0],[100],[10]]0not run yetsample
[[5],[8],[4]]-1not run yetsample