Count Days Without Meetings - Problem
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.
Input & Output
Example 1 — Basic Case with Overlapping
$
Input:
days = 10, meetings = [[5,7],[1,3],[9,10]]
›
Output:
2
💡 Note:
Meeting days are: 1,2,3 (first meeting), 5,6,7 (second meeting), 9,10 (third meeting). Free days are: 4,8. Total free days = 2.
Example 2 — No Meetings
$
Input:
days = 4, meetings = []
›
Output:
4
💡 Note:
No meetings scheduled, so all 4 days (1,2,3,4) are free for work.
Example 3 — All Days Busy
$
Input:
days = 3, meetings = [[2,4]]
›
Output:
1
💡 Note:
Meeting covers days 2,3. Only day 1 is free (day 4 is beyond the available days). Free days = 1.
Constraints
- 1 ≤ days ≤ 109
- 0 ≤ meetings.length ≤ 1000
- 1 ≤ starti ≤ endi ≤ days
Visualization
Tap to expand
Understanding the Visualization
1
Input
days=10, meetings=[[5,7],[1,3],[9,10]]
2
Process
Identify busy days from meetings
3
Output
Count remaining free days
Key Takeaway
🎯 Key Insight: Convert overlapping intervals into non-overlapping ones, then count the gaps between them
💡
Explanation
AI Ready
💡 Suggestion
Tab
to accept
Esc
to dismiss
// Output will appear here after running code