★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
➤微信公众号:山青咏芝(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 }