Question d’entretien chez eBay

Tree and graph BFS problem