일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- 딥러닝
- omscs
- 머신러닝
- 컴퓨터과학과
- 방송통신대학교
- zeros
- cpp
- 조지아텍
- 알고리즘
- 온라인석사
- LAA
- 매트랩
- EOI
- 코딩테스트
- 마니토바
- C++
- 개발자
- 선형대수
- 프로그래머스
- 캐나다 영주권
- machine learning
- Deep learning
- leetcode
- LV1
- MATLAB
- 주정부이민
- mpnp
- Plotting
- 방통대
- 기본
Archives
- Today
- Total
Krononberg
1605. Find Valid Matrix Given Row and Column Sums.cpp 본문
class Solution {
public:
vector<vector<int>> restoreMatrix(vector<int>& rowSum, vector<int>& colSum) {
int m = rowSum.size();
int n = colSum.size();
vector<vector<int>>res(m,vector<int>(n));
for(int i =0; i< m; i++){
for(int j =0; j<n; j++){
res[i][j] = min(rowSum[i],colSum[j]);
rowSum[i] -= res[i][j];
colSum[j] -= res[i][j];
}
}
return res;
}
};
'개발 로그 > 알고리즘' 카테고리의 다른 글
1382. Balance a Binary Search Tree.cpp (0) | 2021.10.04 |
---|---|
763. Partition Labels.cpp (0) | 2021.10.03 |
1252. Cells with Odd Values in a Matrix.cpp (0) | 2021.10.02 |
1725. Number Of Rectangles That Can Form The Largest Square.cpp (0) | 2021.10.02 |
894. All Possible Full Binary Trees.cpp (0) | 2021.10.02 |