Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Find Free Time Slots

MediumPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Find Free Time Slots. Start with the requirements on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

Amazon Advertising scheduling tools represent meetings as time intervals. Given an ordered list of scheduled meetings and the boundaries of a workday, return every interval during which the individual is free, using the same [start, end] format.

Meetings use half-open intervals: a meeting [start, end] occupies times from start inclusive to end exclusive. The input is ordered by nondecreasing start time, but meetings may overlap. Overlapping or touching meetings should be treated as one busy period. Return only free intervals with positive duration.

Formal Specification

Implement find_free_time(meetings, day_start, day_end), where meetings is a list of two-element integer lists and day_start and day_end are integer minute offsets from midnight. All meetings are valid and lie within the workday. Return a list of two-element integer lists representing free intervals in chronological order.

Constraints

  • 0 <= day_start < day_end <= 1440
  • 0 <= len(meetings) <= 10^5
  • Each meeting satisfies day_start <= start < end <= day_end
  • Meetings are ordered by nondecreasing start time

Function Signature

def find_free_time(meetings, day_start, day_end):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output