Skip to content

Count Days Without Meetings

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

An employee is available on days 1 to days. meetings[i] = [start, end] books every day from start to end, inclusive. Meetings may overlap. Return how many days have no meeting at all.

days = 10, meetings = [[5, 7], [1, 3], [9, 10]]  →  2   (days 4 and 8)
days = 5,  meetings = [[2, 4], [1, 3]]           →  1   (day 5)
days = 6,  meetings = [[1, 6]]                   →  0

Constraints

  • 1 <= days <= 10^9
  • 1 <= meetings.length <= 10^5
  • 1 <= start <= end <= days