Question d’entretien chez Google

Difficult data structure and algorithms question