Intervals with Exactly One Person Online
Updated
Problem statement
You receive one online schedule for each person. schedules[p] contains that person's half-open intervals [start, end).
A person's own intervals may be unsorted, overlapping, or adjacent. Merge them first so that one person is never counted more than once at the same time.
Return every maximal non-empty half-open interval during which exactly one distinct person is online. Return the intervals in increasing start-time order. Adjacent ranges are merged whenever the number of online people remains exactly one across their shared boundary.
Function
exactlyOneOnline(schedules: int[][][]) → int[][]Examples
Example 1
schedules = [[[1,4],[6,8]],[[2,5]],[[7,9]]]return = [[1,2],[4,5],[6,7],[8,9]]Exactly one person is online before the first overlap, after the first overlap, before the second overlap, and after it.
Example 2
schedules = [[[1,5],[3,7]],[[6,8]]]return = [[1,6],[7,8]]The first person's intervals merge to [1,7). Both people are online on [6,7).
Constraints
0 <= schedules.length <= 100000.- The total number of intervals across all people is at most
200000. - Every interval contains two integers with
start < end. - Every endpoint is in
[-10^9, 10^9].
More Google Onsite Interview questions
- Route Pattern MatcherPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Evaluate a Nested Math ExpressionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Distinct Subset SumsONSITE INTERVIEW · Seen Nov 2026
- Playlist With No Same Artist in a RowONSITE INTERVIEW · Seen Nov 2026
- 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
Similar questions at other companies
- Worker Management with Promotions and Double-Paid TimeInstacart · ONSITE INTERVIEWInstacart interview questions
- Calendar Event System with Pagination and IntersectionLead Bank · ONSITE INTERVIEWLead Bank 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
- Query Weekly Store Opening HoursApple · PHONE SCREENApple interview questions
- Longest Uninterrupted Work BlockIntuit · PHONE SCREENIntuit interview questions
- Track Received Byte RangesRoblox · OARoblox interview questions
- Highlight and Rank Overlapping CitationsHarvey · PHONE SCREEN · ONSITE INTERVIEWHarvey interview questions
- GPU Credit LedgerOpenAI · PHONE SCREEN · ONSITE INTERVIEWOpenAI interview questions