Looking for interview question: Matrix grid- count number of different colors/numbers/etc.

I had an interview question with some random small company a few months back that I was wondering if was on here. Unfortunately I don't recall the name of it, but hopefully what I recall of the question is enough to find something similar (please do not provide the answer, I'm hoping to try to solve it). It was something about nation regions split up by colors but it came down to a matrix as such:

[ 5, 2, 1, 1, 1 ]
[ 0, 2, 2, 1, 1 ]
[ 0, 2, 3, 5, 5 ]
[ 2, 3, 3, 5, 5 ]

Where a "region" was only considered part of the same group if the numbers were non-diagnol neighbors. In the example above:

Bottom left 2 is its own nation (not part of the larger groups of 2's)
Bottom right 5's & top left 5 are separate nations.
Total nations in that matrix: 7

Would anyone be able to direct me to a similar question on here?

Comments (2)