Skip to content

Practice Count Artifacts That Can Be Extracted

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#2201
LeetCode Problem

Count Artifacts That Can Be Extracted

Problem Statement

On an n by n grid, artifacts[i] = [r1,c1,r2,c2] gives the inclusive top-left and bottom-right corners of a buried rectangle. dig lists the cells excavated. Count artifacts whose every covered cell is excavated. Artifacts do not overlap, each covers at most four cells, and dig contains no repeated cells.

Source: Count Artifacts That Can Be Extracted on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
n = 2, artifacts = [[0,0,0,0],[0,1,1,1]], dig = [[0,0],[0,1]]
Output
1

# Example 2

Input
n = 2, artifacts = [[0,0,0,0],[0,1,1,1]], dig = [[0,0],[0,1],[1,1]]
Output
2

Constraints

1 <= n <= 1000
1 <= artifacts.length, dig.length <= min(n^2, 10^5)
artifacts[i].length == 4
dig[i].length == 2
0 <= r1i, c1i, r2i, c2i, ri, ci <= n - 1
r1i <= r2i
c1i <= c2i
No two artifacts will overlap.
The number of cells covered by an artifact is at most 4.
The entries of dig are unique.

Related LeetCode Problems

Practice more problems similar to Count Artifacts That Can Be Extracted.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.