Design a support-rotation calendar
viaLeetCode
Problem Design a calendar that tracks a team's support (on-call) rotation: who is primary on any given day, automatic rotation through the team, vacation handling, and a secondary/backup assignee.
Requirements
- getAssignee(date) → primary (and secondary) for that date; a rotation order and shift length (e.g. weekly) configurable per team.
- Vacation/override: when the scheduled person is unavailable, the slot resolves to a replacement (next eligible, or an explicit override) without corrupting the base rotation.
- Swaps between engineers; changes must not rewrite history.
Core design
- Classes: Team(members, rotationOrder, shiftLength), RotationSchedule (computes scheduled assignee for a date arithmetically from a start epoch), Availability/Vacation(member, dateRange), Override(date range, member), Assignment resolver that layers: explicit override → vacation-adjusted → base rotation.
- Resolution is computed, not materialized: store rules (rotation + exceptions), derive any date on demand; optionally cache/materialize the next N weeks for display.
Discussion points
- Layered resolution order and why storing every day as a row is fragile (team changes rewrite the future).
- Secondary assignment strategy: next-in-rotation vs dedicated backup rota; ensuring primary ≠ secondary.
- Edge cases: vacation spanning shift boundaries, member leaving the team mid-rotation, time zones/DST at shift handoff, fairness accounting when overrides pile onto one person.
asked …