A CI system runs build jobs on agents, one job per agent at a time. Job i runs from jobs[i][0] until jobs[i][1] (start < end). An agent that finishes a job at time t can start another job at time t.
Write agentsNeeded(jobs) that returns the smallest number of agents that can run every job at its scheduled time. No jobs need no agents.
Input: jobs = [[0,40],[5,15],[20,25]] Output: 2
The job [0, 40] overlaps both others, but [5, 15] and [20, 25] can share an agent.
Input: jobs = [[1,5],[5,9]] Output: 1
The second job starts exactly when the first ends.
0 <= jobs.length <= 10^40 <= start < end <= 10^6Run tries your code on the examples. Submit runs every test, including hidden edge cases, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #398 Fewest Build Agents Needed. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.