290. Meeting Scheduler

You are given two lists of availability slots for two people. Each slot is a list of two integers [start, end], representing the inclusive start time and the exclusive end time of that person's available time.

Your task is to find the earliest time slot that is at least duration minutes long and is common between both people's availability. If there is no such slot, return an empty list.

Example 1:

Input: slots1 = [[10, 50], [60, 120], [140, 210]], slots2 = [[0, 15], [60, 70]], duration = 8

Output: [60, 68]

Explanation:

The only overlapping slot that is at least 8 minutes long is [60, 68].

Example 2:

Input: slots1 = [[10, 50], [60, 120], [140, 210]], slots2 = [[0, 15], [60, 70]], duration = 12

Output: []

Explanation:

Although [60, 70] overlaps, it is only 10 minutes long, which is less than the required 12 minutes.

Now Your Turn!

Pick the correct output for the given input

Input: slots1 = [[10, 20], [30, 40]], slots2 = [[15, 25], [35, 50]], duration = 5

Still unsure what the problem is asking ?

Let’s go through a few more examples, step by step, to make it clearer.

Constraints:

  • 1 <= slots1.length, slots2.length <= 104
  • slots1[i].length, slots2[i].length == 2
  • slots1[i][0] < slots1[i][1]
  • slots2[i][0] < slots2[i][1]
  • 0 <= slots1[i][j], slots2[i][j] <= 109
  • 1 <= duration <= 106

Hints

Frequently Occurring Doubts

Interview Follow-up Questions

Fun Facts

0
class Solution {
public:
vector<int> minAvailableDuration(vector<vector<int>>& slots1, vector<vector<int>>& slots2, int duration) {
//Your Code Goes Here
}
};
Test Case

Input:

Duration
Slots1
Slots2