Bird
Raised Fist0

Given the input schedule = [[[1,2],[5,6]], [[1,3]], [[4,10]]], what is the final returned list of free time intervals?

easy🧾 Code Trace Q12 of Q15
Intervals - Employee Free Time
Consider the following code snippet implementing the sweep line approach for Employee Free Time. Given the input schedule = [[[1,2],[5,6]], [[1,3]], [[4,10]]], what is the final returned list of free time intervals?
A[[3,4],[6,10]]
B[[3,4]]
C[[3,4],[6,7]]
D[[3,4],[6,10]]
Step-by-Step Solution
  1. Step 1: Sort events and track active intervals

    Events: (1,1),(1,1),(2,-1),(3,-1),(4,1),(5,1),(6,-1),(10,-1). Active counts track busy employees.
  2. Step 2: Identify free intervals when active==0 between events

    Free time occurs between 3 and 4 only, as after 4 active increments again until 10.
  3. Final Answer:

    Option B -> Option B
  4. Quick Check:

    Only [3,4] is free time interval [OK]
Quick Trick: Free time only when no active intervals between events [OK]
Common Mistakes:
MISTAKES
  • Including intervals after 6 incorrectly as free time
Trap Explanation:
PITFALL
  • Misreading event order or active count leads to wrong free intervals.
Interviewer Note:
CONTEXT
  • Tests ability to mentally execute sweep line code and track active intervals.
Master "Employee Free Time" in Intervals

3 interactive learning modes - each teaches the same concept differently

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Intervals Quizzes