Skip to content

Commit bb42edf

Browse files
add 2201
1 parent 58cc037 commit bb42edf

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ _If you like this project, please leave me a star._ ★
88

99
| # | Title | Solutions | Video | Difficulty | Tag
1010
|------|----------------|------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------|-------------|-------------
11+
| 2201 |[Count Artifacts That Can Be Extracted](https://leetcode.com/problems/count-artifacts-that-can-be-extracted/)| [Java](../master/src/main/java/com/fishercoder/solutions/_2201.java) || Medium ||
1112
| 2200 |[Find All K-Distant Indices in an Array](https://leetcode.com/problems/find-all-k-distant-indices-in-an-array/)| [Java](../master/src/main/java/com/fishercoder/solutions/_2200.java) || Easy ||
1213
| 2194 |[Cells in a Range on an Excel Sheet](https://leetcode.com/problems/cells-in-a-range-on-an-excel-sheet/)| [Java](../master/src/main/java/com/fishercoder/solutions/_2194.java) || Easy ||
1314
| 2190 |[Most Frequent Number Following Key In an Array](https://leetcode.com/problems/most-frequent-number-following-key-in-an-array/)| [Java](../master/src/main/java/com/fishercoder/solutions/_2190.java) || Easy ||
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package com.fishercoder.solutions;
2+
3+
public class _2201 {
4+
public static class Solution1 {
5+
public int digArtifacts(int n, int[][] artifacts, int[][] dig) {
6+
int ans = 0;
7+
boolean[][] grid = new boolean[n][n];
8+
for (int[] d : dig) {
9+
grid[d[0]][d[01]] = true;
10+
}
11+
for (int[] arti : artifacts) {
12+
int r0 = arti[0];
13+
int c0 = arti[1];
14+
boolean cannotUnearth = false;
15+
for (int r = r0; r <= arti[2]; r++) {
16+
for (int c = c0; c <= arti[3]; c++) {
17+
if (!grid[r][c]) {
18+
cannotUnearth = true;
19+
break;
20+
}
21+
}
22+
if (cannotUnearth) {
23+
break;
24+
}
25+
}
26+
if (!cannotUnearth) {
27+
ans++;
28+
}
29+
}
30+
return ans;
31+
}
32+
}
33+
}

0 commit comments

Comments
 (0)