gutty333
gutty333

Reputation: 1

Counting holes in a Bitmap

Hello I am having an issues with these two matrix and fully understanding the problem. I understand the rule is that a hole is when there is a connected group of 0s in one or more of four directions: up, down, left, or right. But the issues is with the answer to these matrix

This one is 3, but to my understanding I am getting 2

0 1 1 1 1
0 1 1 0 1
0 0 0 1 1
1 1 1 1 0

This one below here is 2, to my understanding I agree with

1 0 1 1
0 0 1 0

So in all, why is it that the first one results in 3?

Upvotes: 0

Views: 1297

Answers (1)

btilly
btilly

Reputation: 46409

Diagonal is NOT up, down, left or right. So the 0 in the upper right is an hole all by itself and not part of the group of 5 near it.

Upvotes: 1

Related Questions