Yandex Interview Question

two easy-medium leetcode problems