diff --git a/LeetCode/1605_Find_Valid_Matrix_Given_Row_and_Column_Sums.py b/LeetCode/1605_Find_Valid_Matrix_Given_Row_and_Column_Sums.py new file mode 100644 index 0000000..5631572 --- /dev/null +++ b/LeetCode/1605_Find_Valid_Matrix_Given_Row_and_Column_Sums.py @@ -0,0 +1,13 @@ +class Solution: + def restoreMatrix(self, rowSum: List[int], colSum: List[int]) -> List[List[int]]: + m = len(rowSum) + n = len(colSum) + matrix = [[0]*n for i in range(m)] + print(matrix) + for i in range(m): + for j in range(n): + matrix[i][j] = min(rowSum[i],colSum[j]) + rowSum[i] -= matrix[i][j] + colSum[j] -= matrix[i][j] + return matrix + \ No newline at end of file