Count how many days in a fixed range are not covered by any meeting interval.
You are given a positive integer days, representing a calendar with days numbered from 1 to days, and a list of meeting intervals. Each meeting interval is described by its start and end day, inclusive.
A day is considered busy if it lies inside at least one meeting interval. Otherwise, it is a free day.
Return the number of free days that are not covered by any meeting.
Input Format
days: total number of days in the calendar.meetings: a list of intervals[start, end], where each interval is inclusive.
Each interval satisfies 1 <= start <= end <= days.
Output Format
- Return an integer: the count of days in
1..daysthat do not belong to any meeting interval.
Constraints
1 <= days0 <= meetings.length- Each meeting interval is inclusive.
- Intervals may overlap or touch.
Example 1
Input
days = 10 meetings = [[1,2],[4,5],[7,7]]
Output
5
Explanation
Covered days are {1,2,4,5,7}. The free days are {3,6,8,9,10}, so the answer is 5.
Example 2
Input
days = 6 meetings = [[1,3],[2,4],[4,6]]
Output
0
Explanation
All days from 1 to 6 are covered after merging the overlapping intervals.
Premium problem context
Unlock deeper context for this problem
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.