All practice tasks

Coding (Platform)

Controlled selection reducer

react · Easy · controlled state

A controlled React table receives a new set of selectable rows after filtering. The local reducer keeps removed IDs and emits duplicate change events.

Task

Reduce replace, toggle and select-all events into a valid ordered selection and a minimal list of emitted snapshots.

Contract

Input is {availableIds,initialSelected,events}. replace carries availableIds; toggle carries id; all carries checked. Return {selected,emissions}.

Acceptance criteria

  • Keep selection in available-ID order.
  • Ignore toggles for unavailable IDs.
  • Emit only when the selected IDs actually change.
  • Prune selection after replace.

Constraints

  • Do not mutate caller-owned input.
  • Keep the supplied framework adapter and public contract unchanged.
  • Add candidate tests for at least one boundary not covered by the public cases.

Editable files

  • src/repair.js — Task-specific state or service boundary
  • tests/candidate.test.js — Candidate-authored regression

What this task practices

Controlled selection reducer is a coding (platform) interview exercise that trains prompt interpretation, explicit assumptions, a concrete response, and a clear explanation of tradeoffs. The catalog marks it as easy difficulty. It focuses on State Modeling, Regression Testing, Technical Reasoning. The signed-in workspace provides the tools for the round and evaluates the attempt against task-specific criteria. Reference solutions, hidden checks, evaluator instructions, and candidate work remain private.

Sign in to startThe workspace and evaluation open after sign in.