Description
Submission
class Solution { public: vector<vector<int>> restoreMatrix(vector<int>& rowSum, vector<int>& colSum) { int n = rowSum.size(); int m = colSum.size(); vector<vector<int>> ret(n, vector<int>(m, 0)); for(int i = 0; i < n; ++i) { for(int j = 0; j < m; ++j) { ret[i][j] = min(rowSum[i], colSum[j]); rowSum[i] -= ret[i][j]; colSum[j] -= ret[i][j]; } } return ret; } };