프로그래머스
1. 시뮬레이션
def solution(sizes):
sizes = [sorted(i) for i in sizes]
width = [i[0] for i in sizes]
height = [i[1] for i in sizes]
return max(width) * max(height)
2. JavaScript
function solution(sizes) {
let width = 0, height = 0;
for (let size of sizes){
width = Math.max(width, Math.max(size[0], size[1]));
height = Math.max(height, Math.min(size[0], size[1]));
}
return width * height;
}
3. C++
#include <string>
#include <vector>
using namespace std;
int solution(vector<vector<int>> sizes) {
int width = 0;
int height = 0;
for (vector<int> size : sizes) {
width = max(width, max(size[0], size[1]));
height = max(height, min(size[0], size[1]));
}
return width * height;
}