Minimum Servers for Cyclic Daily Tasks
Reported by candidates from Google's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
A task that starts at minute 1430 and runs 30 minutes wraps past midnight, and that one detail is what the Google OA reported in February 2026 is built around. It's a circular interval problem: find the peak number of tasks running at the same moment on a 1440-minute clock. Tasks repeat daily, so the end of the day feeds into the start of the next. The sweep itself is easy. The wraparound is where people lose points. If you blank on the circular handling during the live assessment, StealthCoder is the invisible safety net that can hand you the structure.
The problem
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[][]) → int Examples Example 1 tasks = [[1380,60],[0,30],[1380,30]] return = 2 The 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 = 2 The 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 = 2 The 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.
Reported by candidates. Source: FastPrep
Pattern and pitfall
The trick is a difference array over 1440 minutes. For each task, add 1 at start and subtract 1 at (start + duration). If the end goes past 1440, split it: add 1 on [start, 1440) and add 1 on [0, end - 1440). Then prefix-sum and take the max. Half-open intervals mean an end at t frees the server at t, so the decrement lands exactly at t, which handles the midnight reuse case in Example 1. The pitfall is duration 1440. That task covers every minute, so it adds 1 to the entire array. Handle it cleanly or the split logic double counts the start minute. Don't sort 200000 events when a fixed 1440 array does it in O(n + 1440). StealthCoder is your hedge if the wrap logic slips under pressure.
The honest play: practice the pattern, and have StealthCoder ready for the one you didn't see coming.
You can drill Minimum Servers for Cyclic Daily Tasks 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 for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Google's OA.
Google reuses patterns across OAs. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Minimum Servers for Cyclic Daily Tasks FAQ
What's the trick to Minimum Servers for Cyclic Daily Tasks?+
Minimum servers equals the maximum number of tasks active at any single minute. Use a difference array of size 1440, mark starts and ends, and take the max prefix sum. The only twist is tasks that wrap past midnight, which you split into two ranges.
How do I handle tasks that cross midnight?+
If start + duration exceeds 1440, add 1 over [start, 1440) and another 1 over [0, start + duration - 1440). Since the schedule repeats daily, the wrapped part lands at the beginning of the same array, so no extra simulation is needed.
Why does the half-open interval matter here?+
A task ending at minute t doesn't occupy minute t. So you decrement the counter at t, not t+1. That's why Example 1 reuses a server when the 60-minute task ends exactly at midnight and the 00:00 task begins.
What about a task with duration 1440?+
It's active every minute, so it contributes 1 to the whole day. In Example 3 it forces one dedicated server, and the other tasks need at most one more. Treat it as a full-range add so your split logic doesn't count the start minute twice.
How should I prepare for this in 48 hours?+
Practice the difference array and sweep pattern on meeting-rooms style problems, then do one circular variant with wraparound. Write the split-at-1440 logic until it's automatic. Test against the three examples, plus a single full-day task, before the OA.