Pregunta de entrevista de Microsoft

A 2d array question about connected islands.