bugfree Icon
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course

Leetcode Problem 1229. Meeting Scheduler

1229. Meeting Scheduler

Leetcode Solutions

Two Pointers Approach

  1. Sort slots1 and slots2 by their start times.
  2. Initialize pointer1 and pointer2 to 0.
  3. While pointer1 is less than the length of slots1 and pointer2 is less than the length of slots2: a. Calculate the overlap start time as the maximum of slots1[pointer1][0] and slots2[pointer2][0]. b. Calculate the overlap end time as the minimum of slots1[pointer1][1] and slots2[pointer2][1]. c. If the overlap duration is at least duration, return [overlap start time, overlap start time + duration]. d. If slots1[pointer1][1] is less than slots2[pointer2][1], increment pointer1. Otherwise, increment pointer2.
  4. If no common slot is found, return an empty array.
UML Thumbnail

Heap Approach

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...