Available question text
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.
Related questions
Continue with questions that share topics or the same question type.
- The first was leetcode Set Matrix Zeroes.
The LeetCode problem Set Matrix Zeroes is a classic 2D array manipulation problem. The description is as follows:
You are given an
𝑚
×
𝑛
m×n matrix of integers. If any element is 0, you must set its entire row and column to 0. In other words, for each cell that contains 0, all cells in the same row and column should be changed to 0.
Coding
- Find Array Given Subset Sums
Coding
- Check if Every Row and Column Contains All Numbers
Coding
- Count Non Decreasing Arrays With Given Digit Sums
Coding · Array · Dynamic Programming · Prefix Sum
Sources · 1 reference
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 1 record
No company association
Leetcode 1605. Find Valid Matrix Given Row and Column Sums
Reported date not specified · 0 source reports
Source snapshot: Nov 12, 2026
View source