Code Room
CodingHardcod-g702
Subject Min cost flowLevel Senior–Staff~40 minCommon in Algorithms & data structures interviewsIndustries Software development, Technology

Question

You run a fulfillment network. supply[i] units sit at warehouse i; demand[j] units are needed at store j; shipping one unit from warehouse i to store j costs cost[i][j]. Total supply equals total demand. Any warehouse can ship to any store. Return the minimum total shipping cost to satisfy all demand. Constraints: 1 <= len(supply), len(demand) <= 50; 0 <= supply[i], demand[j] <= 1000; 0 <= cost[i][j] <= 1000.

Implement
min_transport_cost(supply: list[int], demand: list[int], cost: list[list[int]]) → int
Examples
in[[3,4],[2,5],[[2,1],[3,2]]]out13
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.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.