Question d’entretien chez Endex (NY)

Standard Hackrank Data structure Question. The real difficulty is the time aspect.