Consider a binary 2d array. I'm trying to count the number of connected zeros such that the shape created by these zeros is surrounded entirely by 1s (and hence, not on the boundary). I only need to know whether at least 1 hole exists in the array.
Examples of holes:
1 hole
111
101
101
111
1 hole
0000
1011
0110
1001
1011
1110
Invalid examples of holes:
101
111
001
01111
11001
10001
10001
10011
10111
I've looked at the 'number of islands' problem and connected components but I can't seem to find a way to adapt these for this problem. The main issue I'm having is making sure that when a collection of 0s includes a border digit, it is still counted as a hole.
Does anyone know what the right direction to go in would be for this problem?