Yandex Interview Question

Classic algorithm, data strutures and etc.