Amazon Interview Question

Number of islands question on leetcode