Algorithm
[프로그래머스] 86491번 최소직사각형 C++
SoyeonCha
2024. 11. 13. 11:25
문제 링크 : https://school.programmers.co.kr/learn/courses/30/lessons/86491
맞힌 코드
#include <bits/stdc++.h>
using namespace std;
int solution(vector<vector<int>> sizes) {
int w = 0;
int h = 0;
for (int i=0; i<sizes.size(); i++){
if (sizes[i][0]<sizes[i][1]){
int temp = sizes[i][0];
sizes[i][0] = sizes[i][1];
sizes[i][1] = temp;
}
if (sizes[i][0]>w)
w = sizes[i][0];
if (sizes[i][1]>h)
h = sizes[i][1];
}
return w*h;
}