Does anyone know how they would approach this problem in an optimal way?
Davy has buried pieces of his ancient artifacts underground. The artifacts are hidden in an area split into an NxN grid of square cells. The rows are numbered from 1 to N. The columns are labeled with consecutive English upper-case letters (A, B, C, etc.). Each cell is identified by a string composed of its row number followed by its column number: for example, "9C" denotes the third cell in the 9th row, and "15D" denotes the fourth cell in the 15th row.
Jack was out looking for the artifact pieces in this area. He chose some map cells in which to search for artifact pieces. He is able to reconstruct an artifact if he found all of the pieces of an artifact.
The goal is to count the number of artifacts for which he has found all of the pieces, as well the number of artifacts for which he's found some but not all of the pieces.
Davy hid the pieces of each artifact in adjacent cells of an area that is rectangular in shape and no larger than 4 cells in area, with at most one piece in each cell. The locations of the artifacts are given as a string artifacts, containing pairs of positions describing respectively the top-left and bottom-right corner cells where pieces of an artifact is buried. The artifacts' locations are separated by a comma.
For example, for the following input artifacts = "1B 2C, 2D 4D", N = 4, the artifact pieces are as shown below (labeled with 1s and 2s).

The coordinates where Jack searched are given as a string searched, containing positions describing the map cells where he searched: for the map in the example shown above and searched = "2B 2D 3D 4D 4A", he will have found artifact pieces in the cells marked with x and found nothing in the cells marked with o.

Artifacts in artifacts and locations in searched may appear in any order.
Write a function:
public int[] solution(int n, String artifacts, String searched);
that, given the size of the map N and two strings artifacts, searched that describe the positions of hidden artifacts and searched locations respectively, returns an integer array with two elements: the count of artifacts which can be reconstructed and the count of artifacts for which some but not all pieces were found.
For instance, given N 4, artifacts = "1B 2B, 2D 40", searched = "2B 2D 3D 4D 4A", your function should return [1,1], as explained above.

Given N = 3, artifacts = "1A 1B, 2C 2C", searched = "18", your function should return [0,1], because he found a piece of one artifact but could not reconstruct any artifacts.
Assume that:
Is there any way of doing this besides building a 2D matrix and adding all the values and then removing them and then checking to see which items were found?