- 脑筋急转弯
function restoreMatrix(rowSum: number[], colSum: number[]): number[][] {
const results: number[][] = new Array(rowSum.length).fill(null).map(() => new Array(colSum.length).fill(0));
for (let row = 0; row < rowSum.length; ++row) {
for (let col = 0; col < colSum.length; ++col) {
results[row][col] = Math.min(rowSum[row], colSum[col]);
rowSum[row] -= results[row][col];
colSum[col] -= results[row][col];
if (!rowSum[row]) {
break;
}
}
}
return results;
};