Max flow network

Write codeHard45 min

Your task

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.

Examples

max_flow(n: int, edges: list[list[int]], s: int, t: int) -> int
Example 1
Inputmax_flow(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)
Output19