You are given a 2D integer array intervals, where intervals[i] = [left_i, right_i] describes the i-th interval starting at left_i and ending at right_i (inclusive). The size of an interval is defined as the number of integers it contains, or more formally right_i - left_i + 1. You are also given an integer array queries. The answer to the j-th query is the size of the smallest interval i such that left_i <= queries[j] <= right_i. If no such interval exists, the answer is -1. Return an array containing the answers to the queries.
Example 1
Input: intervals = [[1,4],[2,4],[3,6],[4,4]], queries = [2,3,4,5]
Output: [3,3,1,4]
Explanation: Query 2 is covered by [1,4] (size 4) and [2,4] (size 3), so the answer is 3. Query 3 is also best covered by [2,4] (size 3). Query 4 fits in [4,4] (size 1). Query 5 is only inside [3,6] (size 4).
Example 2
Input: intervals = [[2,3],[2,5],[1,8],[20,25]], queries = [2,19,5,22]
Output: [2,-1,4,6]
Explanation: Query 2 fits in [2,3] (size 2). No interval contains 19, so its answer is -1. Query 5 fits best in [2,5] (size 4), and 22 is inside [20,25] (size 6).
Example 3
Input: intervals = [[1,4]], queries = [1]
Output: [4]
Explanation: The only interval, [1,4], contains 1 and has size 4 - 1 + 1 = 4.
Process queries in increasing order. Add every interval that has started (left <= query) into a min-heap keyed by size, and lazily discard intervals that have already ended (right < query). The heap top is then the smallest covering interval.
Run checks all cases above. Submit evaluates all test cases.