Yandex Interview Question

algoritms tasks from leetcode