Loading...
Loading...
You are given an integer k and a list slots. There are k people, numbered from 0 to k - 1. Each element in slots contains [person, start, end] meaning that person is free from time start up to, but not including, time end.
Every person appears in at least one slot. A person may have several slots, and a person's slots may overlap.
Return true if there is a time at which every person is free. Otherwise, return false.
Note that two slots that only touch, such as [0, 5] and [5, 9], share no time, because time 5 is not included in the first slot.
Input: k = 2
slots = [[0, 20, 25],
[0, 0, 10],
[1, 10, 20],
[1, 25, 30]]
Output: false
Explanation: Person 0 is free from 0 up to 10 and from 20 up to 25. Person 1 is free from 10 up to 20 and from 25 up to 30. Their slots only meet at times 10, 20, and 25, so there is no time at which both are free.
Input: k = 2
slots = [[0, 0, 10],
[0, 20, 25],
[1, 30, 35],
[1, 5, 15]]
Output: true
Explanation: Both people are free at every time from 5 up to 10.
Input: k = 3
slots = [[0, 0, 15],
[0, 20, 25],
[1, 30, 35],
[1, 5, 15],
[2, 0, 5],
[2, 10, 20],
[2, 25, 30]]
Output: true
Explanation: All three people are free at every time from 10 up to 15.
k ≤1000k ≤ slots.length ≤105person < kstart < end ≤1090 to k - 1 appears in at least one slot