Leetcode 252 Meeting Rooms

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.
For example,
Given [[0, 30],[5, 10],[15, 20]],
return false.
Understand the problem:

The problem looks very similar to the merge interval and insert intervals. So the idea is still the same: first sort the intervals according to the start times, then check if there is any overlap. 

所以正確的解法是將intervals中所有的interval都按start time進行排序,然後判斷是否有overlap,如果有overlap就返回false,否則返回true。


The idea is from here

http://buttercola.blogspot.com/2015/08/leetcode-meeting-rooms.html



發佈了123 篇原創文章 · 獲贊 0 · 訪問量 3萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章