-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMeeting_Rooms.cpp
More file actions
44 lines (40 loc) · 989 Bytes
/
Meeting_Rooms.cpp
File metadata and controls
44 lines (40 loc) · 989 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//{ Driver Code Starts
#include <bits/stdc++.h>
using namespace std;
// } Driver Code Ends
// User function Template for C++
class Solution {
public:
bool canAttend(vector<vector<int>> &arr) {
// Your Code Here
sort(arr.begin(), arr.end());
for(int i = 0; i < arr.size()-1; i++)
if(arr[i][1] > arr[i+1][0]) return false;
return true;
}
};
//{ Driver Code Starts.
int main() {
int tc;
cin >> tc;
while (tc--) {
int n;
cin >> n;
vector<vector<int>> arr(n);
for (int i = 0; i < n; i++) {
int x, y;
cin >> x >> y;
arr[i].push_back(x);
arr[i].push_back(y);
}
cin.ignore();
Solution obj;
bool ans = obj.canAttend(arr);
if (ans)
cout << "true" << endl;
else
cout << "false" << endl;
}
return 0;
}
// } Driver Code Ends