Skip to content

Commit 4d75789

Browse files
committed
Meeting Rooms solution
1 parent daa3053 commit 4d75789

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

meeting-rooms/PDKhan.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
class Solution {
2+
public:
3+
/**
4+
* @param intervals: an array of meeting time intervals
5+
* @return: if a person could attend all meetings
6+
*/
7+
bool canAttendMeetings(vector<Interval> &intervals) {
8+
// Write your code here
9+
sort(intervals.begin(), intervals.end(), [](const Interval& a, const Interval& b){
10+
return a.start < b.start;
11+
});
12+
13+
for(int i = 1; i < intervals.size(); i++){
14+
if(intervals[i].start < intervals[i - 1].end)
15+
return false;
16+
}
17+
18+
return true;
19+
}
20+
};

0 commit comments

Comments
 (0)