-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFindNoOfPeopleToPlace1.cpp
More file actions
48 lines (41 loc) · 1.17 KB
/
Copy pathFindNoOfPeopleToPlace1.cpp
File metadata and controls
48 lines (41 loc) · 1.17 KB
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
45
46
47
48
//Time Complexity:O(n^3)
//Space Complexity:O(1)
class Solution {
public:
int numberOfPairs(vector<vector<int>>& points) {
int n=points.size();
int res=0;
for(int i=0;i<n;i++){
//a
int x1=points[i][0];
int y1=points[i][1];
for(int j=0;j<n;j++){
//b
if(i==j){
continue;
}
int x2=points[j][0];
int y2=points[j][1];
if(x1<=x2 && y1>=y2){
bool pointinside=false;
for(int k=0;k<n;k++){
//c
if(k==i || k==j){
continue;
}
int x3=points[k][0];
int y3=points[k][1];
if(x3>=x1 && x3<=x2 && y3<=y1 && y3>=y2){
pointinside=true;
break;
}
}
if(!pointinside){
res++;
}
}
}
}
return res;
}
};