★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
➤微信公衆號:山青詠芝(shanqingyongzhi)
➤博客園地址:山青詠芝(https://www.cnblogs.com/strengthen/)
➤GitHub地址:https://github.com/strengthen/LeetCode
➤原文地址:http://www.javashuo.com/article/p-fzynknna-mb.html
➤若是連接不是山青詠芝的博客園地址,則多是爬取做者的文章。
➤原文已修改更新!強烈建議點擊原文地址閱讀!支持做者!支持原創!
★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★html
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.git
For example,
Given [[0, 30],[5, 10],[15, 20]]
,
return false
.github
給定由開始和結束時間[[s1,e1],[s2,e2],...]
(si < ei)組成的一系列會議時間間隔,肯定一我的是否能夠參加全部會議。微信
例如,spa
給出[[0, 30],[5, 10],[15, 20]]
,code
返回 false
。htm
1 class Solution { 2 func canAttendMeetings(_ intervals:[[Int]]) -> Bool { 3 var intervals = intervals 4 intervals.sort(by: {(arr1:[Int],arr2:[Int]) -> Bool in 5 return arr1.first! < arr2.first!}) 6 for i in 1..<intervals.count 7 { 8 if intervals[i].first! < intervals[i - 1].last! 9 { 10 return false 11 } 12 } 13 return true 14 } 15 }