BugForge
DSA

Minimum Servers for All Jobs

Mediumheapintervalssweep line 00:00

Each job runs during [start, end). One server runs one job at a time. Return the minimum number of servers needed. A server freed at time t can start a job at time t.

Signature

minServers(jobs: int[][]) → int
Example 1
jobs = [[0,30],[5,10],[15,20]]
output = 2
[0,30] overlaps both others → 2
Example 2
jobs = [[7,10],[2,4]]
output = 1

Constraints

  • 1 ≤ n ≤ 10^5
  • 0 ≤ start < end ≤ 10^9
Run checks the examples. Submit runs every hidden test (17, including large inputs that catch slow solutions).