AT&T Interview Question

island count problem from leetcode