Skip to content
BytePatterns

Attend Every Meeting

EasyIntervals#intervals#sorting~15m

Problem

A calendar lists meetings as [start, end] pairs in no particular order. Decide whether one person can sit through every meeting from start to finish. A meeting that ends exactly when another begins is fine, because the person can walk straight from one to the next.

Examples

Input:  meetings = [[0, 30], [5, 10], [15, 20]]
Output: False
Why:    the long meeting swallows both of the others
Input:  meetings = [[7, 10], [2, 4], [4, 7]]
Output: True
Why:    in time order the meetings only touch at their ends
Input:  meetings = []
Output: True
Why:    edge case, an empty calendar has nothing to clash

Hints

0 / 3

Stuck on the idea rather than the code? Meeting Rooms covers it.