Bloomberg interview question

Leetcode: Number of Islands problem