Max Break Time
Reported by candidates from Google's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
Google's "Max Break Time" problem hit the assessment circuit in December 2024, and it's a scheduling puzzle disguised as a simple optimization question. You're given a set of break windows or time slots, and you need to find the maximum contiguous break you can take without overlap. The trap is that candidates often treat it like a greedy sort-and-scan, which works, but miss edge cases around merging intervals. StealthCoder can catch those edge cases in real time if you blank on the merging logic.
Pattern and pitfall
This is an interval merging problem. Sort the breaks by start time, then iterate through and merge any overlapping or adjacent intervals. The maximum break is the longest merged interval. The common pitfall: forgetting to handle adjacent intervals (where one ends exactly when another starts), or failing to track the longest span as you merge. The second pitfall is not sorting correctly or assuming the input is pre-sorted. If you get stuck on the merging step during the live OA, StealthCoder will feed you the exact pattern to walk through. Most candidates solve this in 15-20 minutes once they see it's interval merging.
If you see this problem in your OA tomorrow, the play is to recognize the pattern in 30 seconds. StealthCoder buys you that recognition.
You can drill Max Break Time 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 by an Amazon engineer who passed his OA cold and still thinks the filter is broken.
Get StealthCoderRelated leaked OAs
This OA pattern shows up on LeetCode as merge intervals. If you have time before the OA, drill that.
You've seen the question.
Make sure you actually pass Google's OA.
Google reuses patterns across OAs. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Max Break Time FAQ
Is this just sorting and finding the max gap?+
Not quite. You need to merge overlapping intervals first, then find the longest single merged interval. Sorting is step one, but merging is where the logic lives. Missing the merge step gives you the wrong answer on overlapping breaks.
Do I need to handle breaks that start and end at the exact same time?+
Yes. A break from time 5 to 5 is zero duration. Filter those out early, or handle them as edge cases. Also watch for start > end, which some inputs include as noise.
What if there are no breaks or only one break?+
If there are no breaks, return 0 or null depending on the problem spec. If one break, return its duration. These are the first checks you should code.
Can I solve this without sorting?+
Technically yes if you iterate twice (once to find min/max time, once to scan), but it's slower and error-prone. Sorting is the clean path. O(n log n) is fine for this problem.
How do I know if two intervals should merge?+
Two intervals merge if the end of one is greater than or equal to the start of the next (after sorting by start time). If break1 ends at 10 and break2 starts at 10, they merge into one interval from break1.start to max(break1.end, break2.end).