-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGFG Enemy
28 lines (28 loc) · 875 Bytes
/
GFG Enemy
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
class Solution
{
public:
int largestArea(int n,int m,int k,vector<vector<int>> &enemy)
{
unordered_set<int> col;
unordered_set<int> row;
for(auto &e : enemy){
row.insert(e[0] - 1);
col.insert(e[1] - 1);
}
int rowCount = 0;
int colCount = 0;
for(int i = 0, last = - 1; i <= n; i++){
if(i == n || row.find(i) != row.end()){
rowCount = max(rowCount, i - last - 1);
last = i;
}
}
for(int i = 0, last = -1; i<=m; i++){
if(i == m || col.find(i) != col.end()){
colCount = max(colCount, i - last - 1);
last = i;
}
}
return rowCount*colCount;
}
};