Minimum Interval to Include Each Query
Hard · Intervals · about 35 minutes
Asked at Google, Amazon, Meta.
You are given intervals[i] = [left, right] (inclusive) and an array queries. For each query q, find the size (right - left + 1) of the smallest interval with left <= q <= right, or -1 if none contains q. Return the answers in query order.