Code RoomFeasible circulation
HardPrep Room Coding #1270

Feasible circulation

CodingAlgorithms & data structuresStaff~50 min

You are given a directed graph on n nodes (0..n-1). Each edge is [u, v, low, high]: a flow on that edge must be an integer in [low, high]. Decide whether a feasible circulation exists - an assignment of flow to every edge satisfying its [low, high] bound AND flow conservation at EVERY node (total in == total out, no source or sink). Return true if feasible, else false. Constraints: 1 <= n <= 200; 0 <= low <= high <= 1000.

Implement
feasible_circulation(n: int, edges: list[list[int]]) → bool
Examples
in[3,[[0,1,1,3],[1,2,1,3],[2,0,1,3]]]outtrue
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 50 min
InputExpectedGot
[3,[[0,1,1,3],[1,2,1,3],[2,0,1,3]]]truenot run yetsample