Yandex interview question

Leetcode tasks. No java core or spring questions.