Yandex interview question

Classic algorithm, data strutures and etc.