File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed
algorithms/intervals/count_days Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments