Pergunta de entrevista da empresa Matroid

How can I count the number of islands in a 2D array?