Code RoomSupport roster rotations
EasyPrep Room Coding #4705

Support roster rotations

CodingAlgorithms & data structuresEntry–Mid~16 min

A support roster is filled one night at a time. engineer_teams[i] names the team engineer i belongs to, and the run has shifts consecutive nights. A rotation names one engineer per night, so two rotations differ as soon as any single night differs. Two rules apply: consecutive nights must go to engineers from different teams, since a team that just handed off needs the night to recover, and no engineer may cover more than max_shifts nights across the whole run. Return how many rotations satisfy both rules. A run of zero nights has exactly one rotation, the empty one, so return 1 there. The roster holds at most 5 engineers and the run is at most 7 nights.

Implement
count_oncall_rotations(engineer_teams: list[str], shifts: int, max_shifts: int) → int
Examples
in[["core","core","edge"],2,2]out4
in[["core","edge"],3,2]out2
in[["ops"],1,1]out1
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

0:00 of about 16 min
InputExpectedGot
[["core","core","edge"],2,2]4not run yetsample
[["core","edge"],3,2]2not run yetsample
[["ops"],1,1]1not run yetsample