> ## Documentation Index
> Fetch the complete documentation index at: https://leetcode-py.wisl.dev/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> leetcode-py is a Python LeetCode practice environment generator with one CLI: lcpy. It is not a service or platform.
> Each problem is a directory under leetcode/ with README.md, solution.py, test_solution.py, helpers.py, and playground.ipynb. lcpy gen creates them from JSON templates bundled with the package.
> Examples are backed by tests; copy them verbatim.

# Count Days Without Meetings Python Solution

> Tested Python solution for LeetCode 3169 with 22 pytest cases. Generate a practice environment with lcpy.

LeetCode 3169, [Medium](/catalog/medium). Topics: [Array](/catalog/topics/array), [Sorting](/catalog/topics/sorting). [View on LeetCode](https://leetcode.com/problems/count-days-without-meetings/description/).

Generate this problem as a practice environment: tested reference solution, 22 [parametrized pytest cases](/practice/testing), and a playground notebook:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
lcpy gen -n 3169   # by problem number
lcpy gen -s count_days_without_meetings   # by problem name
```

## 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] = [starti, endi]` 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.

### Examples

```
Input: days = 10, meetings = [[5,7],[1,3],[9,10]]
Output: 2
```

**Explanation:** There is no meeting scheduled on the 4th and 8th days.

```
Input: days = 5, meetings = [[2,4],[1,3]]
Output: 1
```

**Explanation:** There is no meeting scheduled on the 5th day.

```
Input: days = 6, meetings = [[1,6]]
Output: 0
```

**Explanation:** Meetings are scheduled for all working days.

### Constraints

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

## Solution

Reference implementation from [solution.py on GitHub](https://github.com/wislertt/leetcode-py/blob/main/leetcode/count_days_without_meetings/solution.py), full suite in [test\_solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/count_days_without_meetings/test_solution.py):

```python theme={"theme":{"light":"github-light","dark":"github-dark"}}
class Solution:
    # Time: O(n log n)
    # Space: O(n) for sorting
    def count_days(self, days: int, meetings: list[list[int]]) -> int:
        meetings.sort()
        free = 0
        last = 0
        for start, end in meetings:
            if start > last:
                free += start - last - 1
            last = max(last, end)
        return free + days - last
```

## Complexity

| Time | Space |
| - | - |
| O(n log n) | O(n) for sorting |

## Tags

[NeetCode All](/catalog/neetcode).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.