Feasible circulation exists
Given a directed graph with n nodes (0..n-1) and edges [u, v, low, high] specifying that the flow on each edge must satisfy low <= f(u,v) <= high, determine whether a feasible circulation exists: an assignment of edge flows respecting every bound such that flow is conserved (in = out) at every node. Return True if feasible, else False. Lower bounds are non-negative integers with low <= high. Assume 1 <= n <= 200.
Implement
feasible_circulation(n: int, edges: list[list[int]]) → boolExamples
in
[3,[[0,1,1,3],[1,2,1,3],[2,0,1,3]]]outtrueWhat 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
solution.py
InputExpectedGot
[3,[[0,1,1,3],[1,2,1,3],[2,0,1,3]]]truenot run yetsample