Skip to content

Practice Check if All the Integers in a Range Are Covered

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Easy#1893
LeetCode Problem

Check if All the Integers in a Range Are Covered

Problem Statement

You are given a 2D integer array ranges and two integers left and right. Each ranges[i] = [starti, endi] represents an inclusive interval between starti and endi. Return true if each integer in the inclusive range [left, right] is covered by at least one interval in ranges. Return false otherwise. An integer x is covered by an interval ranges[i] = [starti, endi] if starti <= x <= endi.

Source: Check if All the Integers in a Range Are Covered on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
ranges = [[1,2],[3,4],[5,6]], left = 2, right = 5
Output
true

# Example 2

Input
ranges = [[1,10],[10,20]], left = 21, right = 21
Output
false

Constraints

1 <= ranges.length <= 50
1 <= starti <= endi <= 50
1 <= left <= right <= 50

Related LeetCode Problems

Practice more problems similar to Check if All the Integers in a Range Are Covered.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.