https://school.programmers.co.kr/learn/courses/30/lessons/120860
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
function solution(dots) {
var answer = 0;
var minx = Math.min(dots[0][0], dots[1][0], dots[2][0], dots[3][0]);
var maxx = Math.max(dots[0][0], dots[1][0], dots[2][0], dots[3][0]);
var miny = Math.min(dots[0][1], dots[1][1], dots[2][1], dots[3][1]);
var maxy = Math.max(dots[0][1], dots[1][1], dots[2][1], dots[3][1]);
answer = (maxx - minx) * (maxy - miny);
return answer;
}
230526 python
def solution(dots):
xmax = max(dots[0][0], dots[1][0], dots[2][0], dots[3][0])
ymax = max(dots[0][1], dots[1][1], dots[2][1], dots[3][1])
xmin = min(dots[0][0], dots[1][0], dots[2][0], dots[3][0])
ymin = min(dots[0][1], dots[1][1], dots[2][1], dots[3][1])
return (xmax-xmin)*(ymax-ymin)
'코딩테스트 > LV. 0' 카테고리의 다른 글
LV. 0 :: 중복된 숫자 개수 (0) | 2023.01.22 |
---|---|
LV. 0 :: 종이 자르기 (0) | 2023.01.22 |
LV. 0 :: 문자열 정렬하기 1 (0) | 2023.01.22 |
LV. 0 :: 배열 회전시키기 (0) | 2023.01.22 |
LV. 0 :: 숨어있는 숫자의 덧셈 1 (0) | 2023.01.22 |
댓글