Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

LeetCode Medium With Follow-Up

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

Your question is LeetCode Medium With Follow-Up. 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

Anduril's Lattice may receive sensor-processing windows that must run on separate channels whenever their time ranges overlap. Given the requested windows, determine the minimum number of channels required and assign every window to a channel.

Two windows [start, end] do not overlap when end <= start for the next window, so a channel can be reused at that boundary.

Formal Specification

Implement schedule_sensor_windows(windows).

  • Input: windows, a nonempty list of two-element integer lists. windows[i] = [start, end] identifies the time range of the ith request.
  • Output: A two-element list [channel_count, assignments], where channel_count is the minimum number of channels and assignments[i] is the zero-based channel assigned to the original window at index i.
  • Every overlapping pair must receive different channels.
  • Any valid minimum-channel assignment is acceptable. The expected outputs below use deterministic tie-breaking by earliest available channel ID.

Constraints

  • 1 <= len(windows) <= 10^5
  • 0 <= start < end <= 10^9
  • Windows may be provided in any order
  • A channel may be reused when the previous end time equals the next start time

Function Signature

def schedule_sensor_windows(windows):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output