line
with a length sufficient to cover the entire number line we are interested in (in this case, up to 51, since the problem constraints go up to 50).ranges
and update the line
array by incrementing the value at the start index of the range and decrementing the value right after the end index of the range.overlaps
to keep track of the number of overlapping ranges at each point.line
array from index 1 to right
, updating overlaps
by adding the current value of line
at each index.left
to right
(inclusive) the overlaps
value is zero, return false
as that point is not covered by any range.true
.