Question d’entretien chez Booking.com

DFS,BFS-style algorithm question, mid level.