Practice Minimum Interval to Include Each Query
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Minimum Interval to Include Each Query
Problem Statement
You are given a 2D integer array intervals, where intervals[i] = [lefti, righti] describes the ith interval starting at lefti and ending at righti (inclusive). The size of an interval is defined as the number of integers it contains, or more formally righti - lefti + 1. You are also given an integer array queries. The answer to the jth query is the size of the smallest interval i such that lefti <= queries[j] <= righti. If no such interval exists, the answer is -1. Return an array containing the answers to the queries.
Source: Minimum Interval to Include Each Query on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
intervals = [[1,4],[2,4],[3,6],[4,4]], queries = [2,3,4,5]
[3,3,1,4]
# Example 2
intervals = [[2,3],[2,5],[1,8],[20,25]], queries = [2,19,5,22]
[2,-1,4,6]
Constraints
Related LeetCode Problems
Practice more problems similar to Minimum Interval to Include Each Query.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.