🚩 코딩테스트/알고리즘
[프로그래머스] 최소직사각형
딩딩크롱
2022. 9. 5. 22:43
728x90
문제
https://school.programmers.co.kr/learn/courses/30/lessons/86491
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
코드
자바
import java.util.*;
class Solution {
public int solution(int[][] sizes) {
int w = 0;
int h = 0;
for (int[] size : sizes) {
Arrays.sort(size);
w = Math.max(w, size[0]);
h = Math.max(h, size[1]);
}
return w * h;
}
}
파이썬
def solution(sizes):
w = 0
h = 0
for sorted(size) in sizes:
w = max(w, size[0])
h = max(h, size[1])
return w * h
728x90