Review Assignment Board
Problem
A software team prepares a release with a fixed checklist of review tasks, such as copy review, accessibility review, and image review. The reviewer responsible for a task can change, and the team may exchange the reviewers of two tasks during planning.
Design ReviewAssignmentBoard to store the current reviewer for every task and apply those assignment changes.
Requirements
- Initial assignments. For each constructor task ID, its reviewer value is initially the empty string.
- Reviewer replacement.
assignReviewersets the named task's reviewer value to the supplied reviewer ID. - Reviewer exchange.
swapReviewersexchanges the current reviewer values of the two named tasks. - Reviewer lookup.
getReviewerreturns the named task's current reviewer value.
API
| Signature | Returns | Behavior |
|---|---|---|
ReviewAssignmentBoard(taskIds: string[]) | Not applicable | Establishes Initial assignments. |
assignReviewer(taskId: string, reviewerId: string) | void | Applies Reviewer replacement. |
swapReviewers(firstTaskId: string, secondTaskId: string) | void | Applies Reviewer exchange as one paired state change. |
getReviewer(taskId: string) | string | Applies Reviewer lookup. |
Examples
| Step | Operation | Result |
|---|---|---|
| 1 | Construct with ["copy", "image"] | Both review tasks are unassigned. |
| 2 | getReviewer("copy") | "" |
| 3 | assignReviewer("copy", "maya") | No return value |
| 4 | getReviewer("copy") | "maya" |
If copy belongs to maya and image belongs to noah, the release lead can exchange their responsibilities with swapReviewers("copy", "image"). The resulting reviewers are "noah" for copy and "maya" for image.
Constraints
taskIdscontains 1 to 10 distinct values.- Each method task ID belongs to
taskIds; the two IDs passed toswapReviewersare distinct. - Task and reviewer IDs contain 1 to 8 lowercase ASCII letters.
- A testcase performs at most 40 public method calls after construction.
- Official testcases satisfy these constraints, so calls do not fail or throw.
Notes
Calls are sequential and finish in their given order. A swap has one observable post-state in which both reviewer values have been exchanged. Thread safety and blocking are out of scope.