[프로그래머스] 최소 직사각형

leejihun·2022년 6월 17일
0

알고리즘

목록 보기
26/50

https://programmers.co.kr/learn/courses/30/lessons/86491?language=cpp

#include <string>
#include <vector>
#include <algorithm>
 
using namespace std;
 
int solution(vector<vector<int>> sizes)
{
    int w = 0, h = 0;
 
    for (int i = 0; i < sizes.size(); i++)
    {
        w = max(w, max(sizes[i][0], sizes[i][1]));
        h = max(h, min(sizes[i][0], sizes[i][1]));
    }
 
    return w * h;
}

가로길이의 최대값 * 세로길이의 최대값으로 구함

profile
U+221E

0개의 댓글