Amazon Interview Question

Leetcode medium - Number of islands