Decompose rate matrix
A freight desk publishes a rate card as a rectangular table of whole cents, where rates[o][d] is the quoted price to move one pallet from origin depot o to destination depot d. The desk claims every quote is nothing more than an origin handling fee plus a destination handling fee, and an auditor wants that claim checked. Return a flat list holding the origin fees in order followed by the destination fees in order, pinning the split with the convention that destination 0 carries a fee of exactly 0 cents. Fees may come out negative, since a depot can be quoted at a discount. If no pair of fee lists reproduces the whole table, return an empty list. An empty table returns an empty list. Every row has the same length, and a table with at least one row has at least one column.
rate_card_fees(rates: list[list[int]]) → list[int][[[10,14,12],[30,34,32]]]out[10,30,0,4,2][[[5,6],[7,9]]]out[][[[100,250,175],[100,250,175],[40,190,115]]]out[100,100,40,0,150,75]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.
[[[10,14,12],[30,34,32]]][10,30,0,4,2]not run yetsample[[[5,6],[7,9]]][]not run yetsample[[[100,250,175],[100,250,175],[40,190,115]]][100,100,40,0,150,75]not run yetsample