일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- leetcode
- 딥러닝
- 코딩테스트
- 캐나다 영주권
- 방송통신대학교
- 온라인석사
- zeros
- 컴퓨터과학과
- LV1
- 머신러닝
- 기본
- EOI
- MATLAB
- 방통대
- 주정부이민
- 개발자
- 알고리즘
- omscs
- Plotting
- 프로그래머스
- cpp
- 선형대수
- 매트랩
- mpnp
- LAA
- 마니토바
- Deep learning
- machine learning
- 조지아텍
- C++
Archives
- Today
- Total
Krononberg
1380. Lucky Numbers in a Matrix.cpp 본문
🔑 각 컬럼의 최댓값과, 각 로우의 최소값에 해당하는 저장소를 각각 만들고, 서로 같은 수가 있으면 return.
class Solution {
public:
vector<int> luckyNumbers (vector<vector<int>>& matrix) {
int rowSize = matrix.size();
int colSize = matrix[0].size();
vector<int>colMax;
vector<int>rowMin;
vector<int>res;
for(int j =0; j < colSize; j++){
int tmp=INT_MIN;
for(int i =0; i<rowSize; i++){
if(matrix[i][j] > tmp) tmp = matrix[i][j];
}
colMax.push_back(tmp);
cout << tmp << " ";
}
cout << endl;
for(int i =0; i<rowSize; i++){
int tmp=INT_MAX;
for(int j =0; j< colSize; j++){
if(matrix[i][j] < tmp) tmp = matrix[i][j];
}
rowMin.push_back(tmp);
cout << tmp << " ";
}
for(int i =0; i<colMax.size(); i++){
for(int j =0; j< rowMin.size(); j++){
if(colMax[i] == rowMin[j])
res.push_back(colMax[i]);
}
}
return res;
}
};
'개발 로그 > 알고리즘' 카테고리의 다른 글
1935. Maximum Number of Words You Can Type.cpp (0) | 2021.10.27 |
---|---|
1207. Unique Number of Occurrences.cpp (0) | 2021.10.25 |
811. Subdomain Visit Count.cpp (0) | 2021.10.20 |
1448. Count Good Nodes in Binary Tree.cpp (0) | 2021.10.19 |
1742. Maximum Number of Balls in a Box.cpp (0) | 2021.10.18 |