Yandex Interview Question

leetcode (sliding window, tree, two pointers)