Skip to content

Commit ddbb60f

Browse files
authored
Check if the ranges are overlapping | If no, return false
1 parent 3f7e11e commit ddbb60f

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Greedy/canAttendMeetings.cpp

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class Solution {
2+
public:
3+
bool canAttendMeetings(vector<vector<int>>& intervals) {
4+
if(intervals.size()==0) return true;
5+
sort(intervals.begin(), intervals.end());
6+
for(int i = 0; i < intervals.size()-1; ++i) {
7+
if(intervals[i][1] > intervals[i+1][0]) {
8+
// not gonna overlap
9+
return false;
10+
}
11+
}
12+
return true;
13+
}
14+
};

0 commit comments

Comments
 (0)