The interview problem

Practice prompt

Assign workers to tasks at minimum total cost and show why choosing the cheapest available pair can fail.

Original practice, not a reported company interview. Scenarios and numbers are illustrative. Interview date: not applicable. Sources retrieved October 1, 2026.

1. Scope and worked approach

Assume each worker and task participates in at most one assignment and costs add independently. Form a bipartite cost matrix and solve the linear assignment problem. Include dummy nodes or explicit unmatched penalties when matching is optional. Forbidden assignments need a solver-supported constraint or a carefully justified dominating cost. Pairwise scoring alone is not the same as a feasible global assignment.

2. Trace the design or derivation

Construct feasible edges
  → assign costs
  → solve matching
  → inspect unmatched items

A rectangular matrix can leave elements of the larger side unmatched, but that alone may not encode a meaningful rejection cost for all cases. Adding dummy assignments with explicit penalties makes the trade-off visible. Test that a very poor real match is rejected when its cost exceeds the permitted unmatched alternative.

3. Calculate the example

For two workers and two tasks, costs are [[1,2],[2,100]]. Greedy takes cost 1 then must take 100, totaling 101. The cross assignment costs 2+2=4 and is globally optimal.

4. Failure cases and trade-offs

If costs depend on groups of assignments, the additive formulation no longer captures the problem. A complete matching can force implausible pairs unless unmatched options exist. Exact assignment provides consistency but may be too costly for huge dense matrices; gating candidates sparsifies work while risking lost valid matches.

5. Validation, follow-ups and self-review

Enumerate both assignments in the toy case and test unequal set sizes. Follow-up: how would capacity greater than one change the model? Self-review: define feasibility, unmatched cost and the limits of additive scoring.

Sources and related practice

Technical reference: docs.scipy.org — Additive bipartite assignment and rectangular matching.

Source publication/update: Not established. Retrieved October 1, 2026. The workflow, calculations and review exercises are original; this reference is not evidence that a company asked this question.

Continue with Track anonymous objects through a camera view; Resolve customer entities across noisy records.

Continue your preparation

Choose a connected learning path or browse more ML fundamentals questions. Read our editorial method and attribution policy.