Question d’entretien chez ByteDance

BFS / DFS traversal, moderate difficulty