1605.cpp (442B)
1 class Solution { 2 public: 3 vector<vector<int>> restoreMatrix(vector<int> &row, vector<int> &col) { 4 int m = row.size(), n = col.size(); 5 vector<vector<int>> res(m, vector<int>(n, 0)); 6 for (int i = 0; i < m; ++i) { 7 for (int j = 0; j < n; ++j) { 8 res[i][j] = min(row[i], col[j]); 9 row[i] -= res[i][j], col[j] -= res[i][j]; 10 } 11 } 12 return res; 13 } 14 };