Minimum Servers for Cyclic Daily Tasks
Updated
Problem statement
A daily schedule contains tasks represented as [startMinute, duration]. Each task starts at startMinute minutes after midnight, runs continuously for duration minutes, and repeats at the same time every day. A task may cross midnight.
One server can run at most one task at a time. Intervals are half-open: when one task ends at minute t, the same server may run a task that starts at minute t. Return the minimum number of servers needed to run the repeating schedule.
Function
minDailyServers(tasks: int[][]) → intExamples
Example 1
tasks = [[1380,60],[0,30],[1380,30]]return = 2The two tasks starting at 23:00 overlap, so two servers are necessary. The 60-minute task ends exactly at midnight, when the 00:00 task begins, so they may reuse a server.
Example 2
tasks = [[1430,30],[5,20],[30,10]]return = 2The first task wraps through minute 20 and overlaps the task from minute 5 to 25. The third task starts later.
Example 3
tasks = [[100,1440],[200,10],[210,10]]return = 2The full-day task is always active. The two shorter half-open tasks do not overlap each other, so one additional server is enough.
Constraints
1 <= tasks.length <= 200000- Every task is
[startMinute, duration]. 0 <= startMinute < 1440.1 <= duration <= 1440.
More Google Onsite Interview questions
- Delete Nodes and Return Forest RootsONSITE INTERVIEW · Seen Nov 2026
- Dice-Walk Winning ProbabilityPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- First and Last Target Position in a Mountain ArrayONSITE INTERVIEW · Seen Nov 2026
- Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- 0/1 Knapsack with Weight and Volume LimitsONSITE INTERVIEW · Seen Nov 2026
- Batched Subsequence Word MatchesONSITE INTERVIEW · Seen Nov 2026
- Course Schedule Cycle DetectionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Filesystem Entity Total SizeONSITE INTERVIEW · Seen Nov 2026
- Longest Subarray Within an Absolute-Difference LimitONSITE INTERVIEW · Seen Nov 2026
- Reach a Destination Through Scheduled FlightsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
Similar questions at other companies
- Query Weekly Store Opening HoursApple · PHONE SCREENApple interview questions
- Longest Uninterrupted Work BlockIntuit · PHONE SCREENIntuit interview questions
- Calendar Event System with Pagination and IntersectionLead Bank · ONSITE INTERVIEWLead Bank interview questions
- Worker Management with Promotions and Double-Paid TimeInstacart · ONSITE INTERVIEWInstacart interview questions
- Track Received Byte RangesRoblox · OARoblox interview questions
- Deployment Window SchedulerStripe · OAStripe interview questions
- Worker Management (Promotion Track), Part 4: Full-Shift Double PayAirbnb · OAAirbnb interview questions
- Worker Management, Part 4: Double-Paid IntervalsAnthropic · OAAnthropic interview questions
- Merge Overlapping IntervalsAtlassian · PHONE SCREEN · ONSITE INTERVIEWAtlassian interview questions
- Peak Chat Load Across AgentsCresta · PHONE SCREENCresta interview questions