Yandex interview question

two easy-medium leetcode problems