Count Artifacts That Can Be Extracted
specialist · 815 · lc medium +31 · verified · 57.1% accepted · 225 likes · top 52%
Description
There is an n x n 0-indexed grid with buried artifacts. You are given the integer n and a 0-indexed 2D integer array artifacts where artifacts[i] = [r1i, c1i, r2i, c2i] describes the ith artifact:
- (r1i, c1i) is the top-left cell of the artifact.
- (r2i, c2i) is the bottom-right cell.
You excavate certain cells. If all cells of an artifact are excavated, you can extract it.
Given a 0-indexed 2D integer array dig where dig[i] = [ri, ci] marks excavated cells, return the number of artifacts you can extract.
The test cases guarantee:
- No two artifacts overlap.
- Each artifact covers at most 4 cells.
- All entries of dig are unique.
Example 1:
Example 2:
Code