Given a list of intervals and a list of query points, for each query return the size of the smallest interval that contains it; return -1 for a query that no interval contains.
intervals = [[1,4],[2,4],[3,6],[4,4]], queries = [2,3,4,5][3,3,1,4]Solve it in the editor. Sign in free to run your Python or JavaScript against test cases, get a verdict, and track your attempts.
Solve on FeatCode →Problems about ranges — meeting times, event schedules, ranges on a number line — almost always start with sorting the intervals by start (or end) time, then sweeping through them once.
Read the full Intervals guide →
Original problem on LeetCode ↗