Question d’entretien chez Marshall Wace

Algorithmic question (LC hard) with multiple edge cases