All practice tasks

Coding (Algo)

Maximum Replication Throughput

Maximum flow · Hard

A replication topology has directed capacity limits. Flow may split across paths, and reverse residual routes may be needed to improve an earlier allocation.

Return maximum source-to-sink flow.

Input

Call

  • Implement solve(input) and return its result. Do not print from solve.

Input object

{ n:integer, edges:[from:integer,to:integer,capacity:integer][], source:integer, sink:integer }

Input rules

  • Parallel capacities add; source and sink differ.

What each field means

  • n — number of nodes with IDs 0 through n - 1.
  • Each [from, to, capacity] is a directed link with maximum flow capacity.
  • source and sink — distinct start and destination nodes. Parallel link capacities add.

Output

Return value and rules

  • Return the maximum total flow that can reach the sink from the source.
  • Do not exceed any edge capacity. At every other node, incoming and outgoing flow must balance.
  • Return a non-negative number, not routes or per-edge flows.

Constraints

  • 2 <= n <= 60; 0 <= edges.length <= 500
  • Capacities in [0,1000000]; endpoints valid; self-edges are allowed and contribute no useful flow.

Examples

Example 1

{
  "edges": [
    [
      0,
      1,
      3
    ],
    [
      0,
      2,
      2
    ],
    [
      1,
      2,
      1
    ],
    [
      1,
      3,
      2
    ],
    [
      2,
      3,
      3
    ]
  ],
  "n": 4,
  "sink": 3,
  "source": 0
}

Returns

5

Example 2

{
  "edges": [],
  "n": 2,
  "sink": 1,
  "source": 0
}

Returns

0

Required complexity

O(V × E²) time and O(V² + E) space

What this task practices

Maximum Replication Throughput 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.