Code RoomMax flow network
HardPrep Room Coding #1261

Max flow network

CodingAlgorithms & data structuresSenior–Staff~45 min

A directed flow network has n nodes (0..n-1). edges is a list of [u, v, c] meaning a directed pipe from u to v with capacity c. Return the maximum flow value from source s to sink t. Multiple edges between the same pair may appear and must each contribute. Constraints: 1 <= n <= 300; 0 <= c <= 10^6.

Implement
max_flow(n: int, edges: list[list[int]], s: int, t: int) → int
Examples
in[6,[[0,1,10],[0,2,10],[1,3,4],[1,4,8],[2,4,9],[3,5,10],[4,3,6],[4,5,10]],0,5]out19
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

0:00 of about 45 min
InputExpectedGot
[6,[[0,1,10],[0,2,10],[1,3,4],[1,4,8],[2,4,9],[3,5,10],[4,3,6],[4,5,10]],0,5]19not run yetsample