Build a Combined People Schedule
Reported by candidates from Google's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
Google's September 2026 report is a sweep-line problem dressed up as a calendar merge. You get rows of [name,start,end] with times as strings, and you have to split the timeline at every boundary, gaps included. Example 1 has that 80-to-100 gap with an empty name string, and it's the detail that trips people. Interval events plus ordered names. Sorting boundaries and tracking who's active is the whole game. If you blank halfway through the live OA, StealthCoder runs invisibly as a safety net while you finish.
The problem
Each half-open schedule entry is [name,start,end], with integer times written as decimal strings. Return every maximal segment between consecutive distinct boundaries from the minimum start to the maximum end as [start,end,commaSeparatedNames]. Include gaps with an empty name string. Within a segment, names follow their first input-row order. The active-person count for a segment is the number of names in commaSeparatedNames, or zero when that string is empty. Function buildCombinedSchedule(roster: String[][]) → String[][] Examples Example 1 roster = [["Mary","10","40"],["John","30","50"],["Peter","50","80"],["Crystal","100","150"],["Jane","120","180"]] return = [["10","30","Mary"],["30","40","Mary,John"],["40","50","John"],["50","80","Peter"],["80","100",""],["100","120","Crystal"],["120","150","Crystal,Jane"],["150","180","Jane"]] The result splits at every start or end and includes the 80-to-100 gap. Example 2 roster = [["A","0","5"]] return = [["0","5","A"]] One entry creates one segment. Example 3 roster = [] return = [] An empty roster creates no segments. Constraints 0 <= roster.length <= 5000. start < end.
Reported by candidates. Source: FastPrep
Pattern and pitfall
Collect every start and end value, dedupe, and sort them numerically. Parse the strings to integers first, because string sorting puts "100" before "30". Then for each consecutive pair of boundaries, find who's active: a person is in the segment if start <= left and end >= right. With up to 5000 rows, that's up to 10000 boundaries, so a naive scan per segment gets heavy at around 50 million checks. It's fine, but a sweep with events is cleaner. Keep names ordered by first input row, so iterate rows by index or sort the active set by index. Watch the pitfalls: half-open intervals, empty roster returning [], and gaps emitting an empty string. Duplicate names are the sneaky case, so dedupe by first appearance. If the ordering logic slips under time pressure, StealthCoder is the hedge on the live OA.
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 Build a Combined People Schedule 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
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.
Build a Combined People Schedule FAQ
What's the trick in the Google combined schedule problem?+
Treat every start and end as a boundary, sort the distinct ones as integers, and emit one segment between each consecutive pair. For each segment, list the people whose interval covers it. Gaps fall out naturally as segments with an empty name list.
Why do my results come out in the wrong order?+
Two usual causes. You sorted boundaries as strings, so "100" lands before "30". Or you ordered names by start time instead of first input-row order. Parse to ints, and keep each person's original row index for ordering.
How do I handle the half-open intervals?+
An entry [s,e) is active in a segment [l,r) when s <= l and e >= r. Since segments are cut at every boundary, a person is either fully in or fully out. A person ending at 50 isn't active in the segment starting at 50.
What's the complexity, and is it fast enough for 5000 rows?+
Up to 10000 distinct boundaries. A per-segment scan of all rows is roughly O(n^2), about 50 million simple checks, which is usually acceptable. A sweep with add and remove events is faster if you want margin.
How do I prep for this in 48 hours?+
Write the boundary-sort approach once from scratch. Test the three examples, especially the empty roster and the gap case. Then try duplicate boundaries and a single entry. Intervals and sweep line are the pattern, so don't spend time elsewhere.