Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 3b25489

Browse files
Merge pull request vJechsmayr#413 from TrushaT/add-1605-code
Added 1605_Find_Valid_Matrix_Given_Row_and_Column_Sum
2 parents e48dfe8 + 38b1e3b commit 3b25489

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Solution:
2+
def restoreMatrix(self, rowSum: List[int], colSum: List[int]) -> List[List[int]]:
3+
m = len(rowSum)
4+
n = len(colSum)
5+
matrix = [[0]*n for i in range(m)]
6+
print(matrix)
7+
for i in range(m):
8+
for j in range(n):
9+
matrix[i][j] = min(rowSum[i],colSum[j])
10+
rowSum[i] -= matrix[i][j]
11+
colSum[j] -= matrix[i][j]
12+
return matrix
13+

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /