Implement island counting with BFS and DFS | Bloomberg