Class Solution
- java.lang.Object
-
- g1801_1900.s1893_check_if_all_the_integers_in_a_range_are_covered.Solution
-
public class Solution extends Object
1893 - Check if All the Integers in a Range Are Covered.Easy
You are given a 2D integer array
rangesand two integersleftandright. Eachranges[i] = [starti, endi]represents an inclusive interval betweenstartiandendi.Return
trueif each integer in the inclusive range[left, right]is covered by at least one interval inranges. Returnfalseotherwise.An integer
xis covered by an intervalranges[i] = [starti, endi]ifstarti <= 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 <= 501 <= starti <= endi <= 501 <= left <= right <= 50
-
-
-
Constructor Summary
Constructors Constructor Description Solution()
-