I was practicing for an interview and I found the following problem on Glassdoor.
Given a board with black (1) and white (0), black are all connected. find the min rectangle that contains all black. An example given is
0 0 0 0 0
0 1 1 1 0
0 1 1 0 0
0 1 0 0 0
0 0 0 0 0
This problem challenged my understanding of connectedness, will the 1s in the matrix below be considered all connected to each other?
0 0 0 0 0
0 1 0 1 0
0 1 0 1 0
0 1 1 1 0
0 0 0 0 0
Should I considered 8-connectedness by default?