Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

22.01.03 - [PG] 최소직사각형 #180

Closed
suhyunsim opened this issue Jan 3, 2022 · 0 comments
Closed

22.01.03 - [PG] 최소직사각형 #180

suhyunsim opened this issue Jan 3, 2022 · 0 comments
Assignees
Labels
lv.1 프로그래머스 - level 1 성공 맞은 문제 수학 수학

Comments

@suhyunsim
Copy link
Owner

문제

핵심 아이디어

  • 가로를 가장 길게 생각하고 풀이

어려운 점, 실수

풀이

package main.java.com.poogle.PG.Q86491;

public class Solution {

    public static void main(String[] args) {
        System.out.println(solution(new int[][]{{60, 50}, {30, 70}, {60, 30}, {80, 40}}));
        System.out.println(solution(new int[][]{{10, 7}, {12, 3}, {8, 15}, {14, 7}, {5, 15}}));
    }

    private static int solution(int[][] sizes) {
        int maxW = 0;
        int maxV = 0;
        for (int[] size : sizes) {
            int w = Math.max(size[0], size[1]);
            int v = Math.min(size[0], size[1]);
            maxW = Math.max(w, maxW);
            maxV = Math.max(v, maxV);
        }
        return maxW * maxV;
    }
}
@suhyunsim suhyunsim added 성공 맞은 문제 수학 수학 lv.1 프로그래머스 - level 1 labels Jan 3, 2022
@suhyunsim suhyunsim added this to the 1월 1주 차 milestone Jan 3, 2022
@suhyunsim suhyunsim self-assigned this Jan 3, 2022
suhyunsim added a commit that referenced this issue Jan 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lv.1 프로그래머스 - level 1 성공 맞은 문제 수학 수학
Projects
None yet
Development

No branches or pull requests

1 participant