AT&T interview question

island count problem from leetcode