Earliest Common Meeting Time
Reported by candidates from ZipRecruiter's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
The half-open busy intervals in minutes, capped at minute 1440, are the detail that matters in this ZipRecruiter OA reported in September 2024. You get every employee's busy slots and a meeting length, and you return the earliest common free start or -1. The hinted pattern is greedy, and it's really merge intervals plus a sweep. Nothing exotic, but off-by-one errors on the boundaries will sink you. If you blank on the merge step during the live assessment, StealthCoder is the invisible safety net that reads the problem and hands you a working solution.
The problem
You are given one day's meeting schedules for several employees. schedules[i][j] = [start, finish] is a half-open busy interval in minutes from the start of the day. Given a requested meeting length, return the earliest start minute at which every employee is free for the entire meeting. The meeting must finish by minute 1440. Return -1 if no common interval exists. Function earliestCommonMeeting(schedules: int[][][], length: int) → int Examples Example 1 schedules = [[[60,150],[180,240]],[[0,210],[360,420]]] length = 120 return = 240 Every employee is free from minute 240 through minute 360, so 240 is the earliest valid start. Example 2 schedules = [[[480,510]],[[240,330]],[[375,400]]] length = 180 return = 0 All employees are free from minute 0 through minute 180. Constraints 1 <= schedules.length <= 100 0 <= schedules[i].length <= 100 0 <= start < finish <= 1440 1 <= length <= 1440
Reported by candidates. Source: FastPrep
Pattern and pitfall
The trick: flatten every employee's busy intervals into one list and sort by start. Sweep through it while tracking the latest finish seen so far, starting at 0. Before each interval, check the gap: if start minus cursor is at least length, return cursor. Otherwise set cursor to max(cursor, finish). After the loop, check that cursor + length <= 1440, and if so return cursor, else -1. The pitfall is the half-open boundary. An interval ending at 240 means 240 is free, so use >= and not >. Example 1 confirms it: busy ends at 240 and the meeting starts at 240. Another miss is forgetting the empty-schedule employee and the tail gap before 1440. Total work is sorting up to 10,000 intervals, so O(n log n). If the sweep logic slips under pressure in the live OA, StealthCoder is the hedge that covers you.
Drill it cold or hedge it with StealthCoder. Either way, don't walk into the OA hoping you remember the trick.
You can drill Earliest Common Meeting 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. Made for the candidate who got the OA invite this morning and has 72 hours, not six months.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass ZipRecruiter's OA.
ZipRecruiter reuses patterns across OAs. Made for the candidate who got the OA invite this morning and has 72 hours, not six months. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Earliest Common Meeting Time FAQ
What's the trick for Earliest Common Meeting Time?+
Merge all employees' busy intervals into one sorted list, then sweep with a cursor holding the latest finish so far. The first gap between the cursor and the next start that fits the meeting length gives your answer. Check the tail gap up to 1440 at the end.
How hard is this ZipRecruiter OA question really?+
Medium at most. It's a merge-intervals variant with a gap check. The logic is short, but the half-open boundaries and the 1440 cap catch people. If you've done Merge Intervals before, you'll finish it fast.
Why is the pattern tagged greedy?+
Because you scan in sorted order and take the first valid gap. Earliest start means the first gap that fits is optimal, so there's no backtracking or DP. Sorting does the heavy lifting and the sweep is linear.
What edge cases should I test?+
Test an employee with an empty schedule, all employees free all day, a gap exactly equal to length, busy time ending exactly at 1440, and a meeting that would run past 1440. Example 2 returning 0 covers the free-at-start case.
How do I prepare for this in 48 hours?+
Write Merge Intervals and a free-time gap finder from scratch twice. Practice the sort-then-sweep template with a cursor variable. Then run both examples by hand, focusing on the strict versus non-strict comparison at interval boundaries.