Amazon interview question

Island counting problem leetcode bfs