All practice tasks

Coding (Algo)

Maximize Compatible Assignments

Bipartite matching · Hard

A bounded assignment service pairs work items with compatible reviewers. A compatibility edge permits a pair but does not force it. Choosing the first free reviewer for every item can block a later item that has no alternative, so earlier choices may need to be reassigned.

Return the largest number of compatible pairs such that no left item or right reviewer is used more than once.

Input

Call

  • Implement solve(input) and return the result. The provided adapter handles JSON input and output.

Input shape

{ left: integer, right: integer, edges: [integer, integer][] }

Fields

  • left and right are the sizes of two separate sets with indexes 0..left-1 and 0..right-1.
  • Each edge [u,v] permits pairing left item u with right item v. Duplicate edges do not create extra capacity.

Output

Return value

  • Return only an integer maximum count, not the selected pairs.
  • Either empty set or no edges gives zero. Isolated items remain unmatched; an arbitrary greedy matching is not sufficient.

Constraints

  • 0 <= left,right <= 100; 0 <= edges.length <= 10000; all endpoints are valid.
  • Do not mutate input. No external network or solver service is available.

Examples

Example 1

{
  "edges": [
    [
      0,
      0
    ],
    [
      0,
      1
    ],
    [
      1,
      0
    ]
  ],
  "left": 2,
  "right": 2
}

Returns

2

Example 2

{
  "edges": [
    [
      0,
      0
    ],
    [
      0,
      0
    ],
    [
      1,
      0
    ]
  ],
  "left": 2,
  "right": 1
}

Returns

1

Required complexity

O(left * (edges.length + right + 1)) time and O(left + right + edges.length) space

What this task practices

Maximize Compatible Assignments is a coding (algo) interview exercise that trains prompt interpretation, explicit assumptions, a concrete response, and a clear explanation of tradeoffs. The catalog marks it as hard difficulty. It focuses on Technical Reasoning, Testing, Validation. 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.