。゚(*´□`)゚。

코딩의 즐거움과 도전, 그리고 일상의 소소한 순간들이 어우러진 블로그

ㅋㅌ

Math.max, Math.abs

quarrrter 2023. 8. 14. 11:18
class Solution {
    public int solution(int[][] dots) {
        
        int x1 = dots[0][0];
        int x2 = dots[0][0];
        int y1 = dots[0][1];
        int y2 = dots[0][1];
        
        for (int i = 1; i < dots.length; i++) {
            x1 = Math.max(x1, dots[i][0]);
            x2 = Math.min(x2, dots[i][0]);
            y1 = Math.max(y1, dots[i][1]);
            y2 = Math.min(y2, dots[i][1]);
        }


        int width = Math.abs(x1 - x2);
        int height = Math.abs(y1 - y2);

        int area = width * height;

        return area;
    }
}

'ㅋㅌ' 카테고리의 다른 글

[SQL] JOIN  (0) 2023.08.19
[SQL] 날짜 포맷, 오름차순, 내림차순  (0) 2023.08.18
Math.max  (0) 2023.08.11
replace  (0) 2023.08.07
reverseArray, Character.isLowerCase  (0) 2023.08.05