You are given n employees’ working-time intervals, where employee i works during the inclusive interval [startTime[i], endTime[i]].
You want to form a team such that:
Return the maximum possible team size.
startTime = [2, 5, 6, 8]
endTime = [5, 6, 10, 9]
3
Grace Hopper’s scheduling rule: you must assign processes to time slots so that no process occupies two consecutive time slots.
Given:
n_processes = n
(number of distinct processes, labeled
1..n
)
n_intervals = m
(number of time slots)
Count the number of valid allocations (sequences) of length m over n processes such that:
t > 1
,
assignment[t] != assignment[t-1]
Return the count modulo (10^9 + 7).
If n = 3, m = 2, valid sequences include (1,2), (1,3), (2,1), etc., but not (1,1).
n, m
efficiently (assume you may need near
O(log m)
or
O(m)
time, depending on constraints).