1893. Check if All the Integers in a Range Are Covered LeetCode Solution
In this guide, you will get 1893. Check if All the Integers in a Range Are Covered LeetCode Solution with the best time and space complexity. The solution to Check if All the Integers in a Range Are Covered problem is provided in various programming languages like C++, Java, and Python. This will be helpful for you if you are preparing for placements, hackathons, interviews, or practice purposes. The solutions provided here are very easy to follow and include detailed explanations.
Table of Contents
- Problem Statement
- Complexity Analysis
- Check if All the Integers in a Range Are Covered solution in C++
- Check if All the Integers in a Range Are Covered solution in Java
- Check if All the Integers in a Range Are Covered solution in Python
- Additional Resources

Problem Statement of Check if All the Integers in a Range Are Covered
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.
Example 1:
Input: ranges = [[1,2],[3,4],[5,6]], left = 2, right = 5
Output: true
Explanation: Every integer between 2 and 5 is covered:
– 2 is covered by the first range.
– 3 and 4 are covered by the second range.
– 5 is covered by the third range.
Example 2:
Input: ranges = [[1,10],[10,20]], left = 21, right = 21
Output: false
Explanation: 21 is not covered by any range.
Constraints:
1 <= ranges.length <= 50
1 <= starti <= endi <= 50
1 <= left <= right <= 50
Complexity Analysis
- Time Complexity: O(nk), where k = right – left + 1
- Space Complexity: O(1)
1893. Check if All the Integers in a Range Are Covered LeetCode Solution in C++
class Solution {
public:
bool isCovered(vector<vector<int>>& ranges, int left, int right) {
for (int i = left; i <= right; ++i) {
bool seen = false;
for (const vector<int>& range : ranges)
if (i >= range[0] && i <= range[1]) {
seen = true;
break;
}
if (!seen)
return false;
}
return true;
}
};
/* code provided by PROGIEZ */
1893. Check if All the Integers in a Range Are Covered LeetCode Solution in Java
class Solution {
public boolean isCovered(int[][] ranges, int left, int right) {
for (int i = left; i <= right; ++i) {
boolean seen = false;
for (int[] range : ranges)
if (i >= range[0] && i <= range[1]) {
seen = true;
break;
}
if (!seen)
return false;
}
return true;
}
}
// code provided by PROGIEZ
1893. Check if All the Integers in a Range Are Covered LeetCode Solution in Python
class Solution:
def isCovered(self, ranges: list[list[int]], left: int, right: int) -> bool:
return all(any(l <= i <= r for l, r in ranges) for i in range(
left, right + 1))
# code by PROGIEZ
Additional Resources
- Explore all LeetCode problem solutions at Progiez here
- Explore all problems on LeetCode website here
Happy Coding! Keep following PROGIEZ for more updates and solutions.