PS/Programmers
[프로그래머스] 최소직사각형
RUBY_루비
2023. 3. 10. 23:59
출처:: https://school.programmers.co.kr/learn/courses/30/lessons/86491
분류:: 완전탐색
1. 문제 이해 및 해결과정
1) 완전탐색
- 50 60, 30 70, 30 60 . 40 80 -> (x,y) x<y로 각각 정렬 후 max(x) * max(y) |
2. 풀이방법
1) python
def solution(sizes):
answer = 0
arr=[]
maxx=-1
maxy=-1
for x,y in sizes:
if x>y:
arr.append([y,x])
else:
arr.append([x,y])
for x, y in arr:
if x> maxx:
maxx=x
if y> maxy:
maxy = y
return maxx*maxy
3. 오답원인
4. 알게된 점