Skip to content

Points That Intersect With Cars

EasyIntervals
Decode it first. Clues, constraints, pattern and plan before any code.

Cars are parked on a number line. nums[i] = [start, end] means car i covers every integer point from start to end, inclusive. Cars may overlap. Return the number of integer points covered by at least one car.

[[3, 6], [1, 5], [4, 7]]  →  7   (points 1 to 7)
[[1, 3], [5, 8]]          →  7   (1, 2, 3, 5, 6, 7, 8)

Constraints

  • 1 <= nums.length <= 100
  • 1 <= start <= end <= 100