Skip to content
Decoder

Points That Intersect With Cars

Easy

Problem

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.

Example 1

Input
[[3, 6], [1, 5], [4, 7]]
Output
7
Why
points 1 to 7

Example 2

Input
[[1, 3], [5, 8]]
Output
7
Why
1, 2, 3, 5, 6, 7, 8

Constraints

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

Read it once before you touch anything

Want some pressure? Start the timer. In an interview you get about two minutes to understand the problem.

  1. 1Read the goalWhat goes in, what comes out
  2. 2Scan the examplesCheck one by hand
  3. 3Note the constraintsThey set your Big O
Say what it asks in one sentence
Say it out loud first, then compare with ours.