Amazon Interview Question

number of islands question from leetcode