Skip to main content
Back to problems
Leetcode
Medium
Arrays
Intervals
Sorting
Greedy
Google
Meta
Count Days Without Meetings

Count how many days in a fixed range are not covered by any meeting interval.

Acceptance 0%
Problem Statement

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..days that do not belong to any meeting interval.

Constraints

  • 1 <= days
  • 0 <= meetings.length
  • Each meeting interval is inclusive.
  • Intervals may overlap or touch.
Examples
Sample cases returned by the problem API.

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.

Guided hints
Editorial and discussion links
Concept map and variants
Sign in to unlock
Track your progress
Sign in to bookmark this problem, save notes, and manage its revision plan.