Count Artifacts That Can Be Extracted LeetCode solution in Java

1
class Solution {
2
public int digArtifacts(int n, int[][] artifacts, int[][] dig) {
3
HashSet<String> set = new HashSet<>();
4
for (int d[] : dig) set.add(d[0] + " " + d[1]);
5
int c = 0;
6
for (int a[] : artifacts) {
7
boolean done = true;
8
for (int i = a[0]; i <= a[2]; i++) {
9
for (int j = a[1]; j <= a[3]; j++) {
10
if (!set.contains(i + " " + j)) done = false;
11
}
12
}
13
if (done) c++;
14
}
15
return c;
16
}
17
}
18
// TC = O(DIG + N^2)

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0