Leetcode 1605. Find Valid Matrix Given Row and Column Sums
Given vectors rowSum and colSum, construct any non-negative integer matrix whose row and column totals match the given sums (a solution is guaranteed). This is essentially a feasibility/flow problem that can be solved greedily by assigning each cell the minimum of the remaining row and column sums while respecting the equal total-sum constraint.
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
0
Hello Interview Premium
Your account is free and you can post anonymously if you choose.