Yandex interview question

leetcode (sliding window, tree, two pointers)