Count Days Without Meetings

Medium Topics Company Tags

The working period consists of the integer days from 1 through days, inclusive. Each entry [start, end] in meetings marks every day from start through end as occupied, including both endpoints. Meetings may overlap or repeat. Return the number of days in the working period that are not covered by any meeting.

Example 1:

Input: days = 8
meetings = [[2,3],[3,5]]

Output: 4

Explanation: The meetings overlap on day 3 and together occupy days 2 through 5. Days 1, 6, 7, and 8 remain free, giving 4 days.

Example 2:

Input: days = 6
meetings = [[1,2],[3,6]]

Output: 0

Explanation: The first meeting covers days 1 and 2, and the second covers days 3 through 6. Every working day is occupied, so return 0.

Example 3:

Input: days = 9
meetings = [[4,4],[4,4]]

Output: 8

Explanation: Both meetings occupy the same single day, day 4. Count that day only once; the other eight days remain free.

Constraints:

  • 1 <= days <= 1000000000
  • 1 <= meetings.length <= 100000
  • Each meeting has exactly two endpoints.
  • 1 <= start <= end <= days for every meeting.


Topics

Company Tags

Please upgrade to NeetCode Pro to view company tags.