In C# I've come to a problem I can't solve myself. I have a 2d matrix which looks like this
1 1 1 0 0 0 0 1 1 1
1 0 1 0 0 0 0 1 1 1
1 0 1 1 1 1 1 0 1 1
1 0 1 1 1 1 1 0 1 1
1 0 1 1 1 1 1 1 1 1
1 1 1 0 0 1 1 1 1 1
1 1 1 0 0 1 1 1 1 1
I want to find out the biggest 4-connected (north, west, south, east) area of 0
. For the example above the answer is 8
(the biggest area of all zeroes is on the top of the matrix):
0 0 0 0
0 0 0 0
I have no idea how to cope such a task, so anything could help.
Thanks!
I've tried iterating through the matrix with a for
but its not working if the biggest area where 0
are on the same line (or column).