Question d’entretien chez Bloomberg

a hard leet code question about graphs/trees