[프로그래머스, 120860] 직사각형 넓이 구하기 (java)
Problem Solving/Programmers

[프로그래머스, 120860] 직사각형 넓이 구하기 (java)

728x90

https://school.programmers.co.kr/learn/courses/30/lessons/120860

 

프로그래머스

SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프

programmers.co.kr


메모리: 85.3 MB, 시간: 0.06 ms

사용 알고리즘: 구현

class Solution {
    public int solution(int[][] dots) {
        int height = Math.max(Math.max(Math.max(dots[0][0], dots[1][0]), dots[2][0]), dots[3][0])
            - Math.min(Math.min(Math.min(dots[0][0], dots[1][0]), dots[2][0]), dots[3][0]);
        int width = Math.max(Math.max(Math.max(dots[0][1], dots[1][1]), dots[2][1]), dots[3][1])
            - Math.min(Math.min(Math.min(dots[0][1], dots[1][1]), dots[2][1]), dots[3][1]);
        return height * width;
    }
}
728x90