forked from fishercoder1534/Leetcode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_2201.java
33 lines (32 loc) · 1 KB
/
_2201.java
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
package com.fishercoder.solutions;
public class _2201 {
public static class Solution1 {
public int digArtifacts(int n, int[][] artifacts, int[][] dig) {
int ans = 0;
boolean[][] grid = new boolean[n][n];
for (int[] d : dig) {
grid[d[0]][d[01]] = true;
}
for (int[] arti : artifacts) {
int r0 = arti[0];
int c0 = arti[1];
boolean cannotUnearth = false;
for (int r = r0; r <= arti[2]; r++) {
for (int c = c0; c <= arti[3]; c++) {
if (!grid[r][c]) {
cannotUnearth = true;
break;
}
}
if (cannotUnearth) {
break;
}
}
if (!cannotUnearth) {
ans++;
}
}
return ans;
}
}
}