웅재의 코딩세상
[프로그래머스] 최소직사각형 본문
- 풀이
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int solution(vector<vector<int>> sizes) {
int answer = 0;
int width=0, height=0;
for(int i=0; i<sizes.size(); i++){
sort(sizes[i].begin(), sizes[i].end());
}
for(int i=0; i<sizes.size(); i++){
if(sizes[i][0] > width) width = sizes[i][0];
if(sizes[i][1] > height) height = sizes[i][1];
}
return width * height;
}
반응형
'코딩테스트 > 프로그래머스 - LV 1' 카테고리의 다른 글
[프로그래머스] 두 개 뽑아서 더하기 (0) | 2024.02.14 |
---|---|
[프로그래머스] 콜라 문제 (1) | 2024.02.14 |
[프로그래머스] 삼총사 (0) | 2024.02.14 |
[프로그래머스] 문자열 내 마음대로 정렬하기 (0) | 2024.02.13 |
[프로그래머스] k번째수 (0) | 2024.02.13 |