Skip to content

Commit 69e581c

Browse files
refactor(algorithms, intervals, count days): add type hints
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent 8829a96 commit 69e581c

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

algorithms/intervals/count_days/__init__.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,22 @@ def count_days(days: int, meetings: List[List[int]]) -> int:
5454
return free_days + (days - last_busy_day)
5555

5656

57-
def count_days_2(days, meetings):
57+
def count_days_2(days: int, meetings: List[List[int]]) -> int:
58+
"""
59+
Counts the number of days the employee is available for work but has no scheduled meetings.
60+
61+
This implementation merges overlapping meetings and counts total occupied days.
62+
63+
Time Complexity: O(n log n) due to sorting
64+
Space Complexity: O(1) excluding sort overhead
65+
66+
Args:
67+
days (int): The total number of days the employee is available for work
68+
meetings (List[List[int]]): A list of meetings, where each meeting is represented as a list of two integers [start, end]
69+
Note: This function modifies the input list by sorting it in place.
70+
Returns:
71+
int: The number of days the employee is available for work but has no scheduled meetings
72+
"""
5873
# Sort the meetings based on their start time to process them in order
5974
meetings.sort()
6075

0 commit comments

Comments
 (0)