Pergunta de entrevista da empresa Yandex

For all questions related to algorithms their complexity must be calculated