solve calculate-island, with BFS