Pergunta de entrevista da empresa X

Question with finding islands within nested arrays