[LeetCode] Meeting Rooms

252. Meeting Rooms

Given an array of meeting time intervals where intervals[i] = [starti, endi], determine if a person could attend all meetings.

1
2
3
4
5
6
7
8
9
10
11
class Solution {
public:
bool canAttendMeetings(vector<vector<int>>& intervals) {
if(intervals.size() <= 1) return true;
sort(begin(intervals), end(intervals));
for(int i = 0; i < intervals.size() - 1; i++) {
if(intervals[i][1] > intervals[i+1][0]) return false;
}
return true;
}
};
Author: Song Hayoung
Link: https://songhayoung.github.io/2023/07/30/PS/LeetCode/meeting-rooms/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.