Yandex interview question

Some problems from leetcode with different difficulties