Amazon Interview Question

Island counting problem leetcode bfs