Problemcollaborative work board core

Session: Sign in to solve

Solution.txt

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. assignReviewer sets the named task's reviewer value to the supplied reviewer ID.
  • Reviewer exchange. swapReviewers exchanges the current reviewer values of the two named tasks.
  • Reviewer lookup. getReviewer returns the named task's current reviewer value.

API

SignatureReturnsBehavior
ReviewAssignmentBoard(taskIds: string[])Not applicableEstablishes Initial assignments.
assignReviewer(taskId: string, reviewerId: string)voidApplies Reviewer replacement.
swapReviewers(firstTaskId: string, secondTaskId: string)voidApplies Reviewer exchange as one paired state change.
getReviewer(taskId: string)stringApplies Reviewer lookup.

Examples

StepOperationResult
1Construct with ["copy", "image"]Both review tasks are unassigned.
2getReviewer("copy")""
3assignReviewer("copy", "maya")No return value
4getReviewer("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

  • taskIds contains 1 to 10 distinct values.
  • Each method task ID belongs to taskIds; the two IDs passed to swapReviewers are 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.

PRIVATE WORKSPACE

Checking your session…

The statement is public. The editor, editorial, submissions, and saved work are private.