Domanda di colloquio di IMC Trading

Given a 2D array filled with integers, any adjacent element (vertically or horizontally) with the same integer is considered a country. Return how many countries exist in the given array.