Problem Description

Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],...] (si < ei) , determine if a person could attend all meetings

Examples

Example1

Input: intervals = [(0,30),(5,10),(15,20)]
Output: false
Explanation:
(0,30), (5,10) and (0,30),(15,20) will conflict

Example2

Input: intervals = [(5,8),(9,15)]
Output: true
Explanation:
Two times will not conflict

解析

給定一個 2D 陣列 intervals

每個 intervals[i] = [$start_i, end_i$] 代表一個時間區間 $start_i$ < values ≤ $end_i$

遇到重疊時間區間則會無法開會

要求寫一個演算法來判斷給定的時間區間是能否開會

如同 435. Non-overlapping Intervals

可以發現要判斷重疊條件如下圖

Untitled

當 $start_i$ ≤ $start_j$ 時,

$end_j$ > $start_i$ 代表 intervals[i] 與 intervals[j] 有重疊