Mid/SeniorArraySorting

Count Days Without Meetings

You are given a positive integer days representing the total number of days an employee is available for work, starting from day 1. You are also given a 2D array meetings of size n, where meetings[i] = [start_i, end_i] represents the starting and ending days of meeting i, inclusive.

Return the count of days when the employee is available for work but no meetings are scheduled.

Note: The meetings may overlap.

Example 1
        5---7
1---3
                9-10
Inputdays = 10, meetings = [[5,7],[1,3],[9,10]]
Output2
There is no meeting scheduled on the 4th and 8th days.
Example 2
  2---4
1---3
Inputdays = 5, meetings = [[2,4],[1,3]]
Output1
There is no meeting scheduled on the 5th day.

Constraints

  • 1 <= days <= 10^9
  • 1 <= meetings.length <= 10^5
  • meetings[i].length == 2
  • 1 <= meetings[i][0] <= meetings[i][1] <= days

Asked at 4 companies

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate