~๋ชฉ์ฐจ~
๋ฌธ์
https://school.programmers.co.kr/learn/courses/30/lessons/86491?language=java
๋ฌธ์ ํด๊ฒฐ ํฌ์ธํธ
- ๊ฐ ์ง์ฌ๊ฐํ์ ๊ฐ ์ค ํฐ ๊ฐ์ ์ค๋ฅธ์ชฝ(์ธ๋ก) ๋๋ ์ผ์ชฝ(๊ฐ๋ก)์ผ๋ก ๋ชฐ์์ ์ฌ๋ฐฐ์นํ๋ค.
- ์ฌ๋ฐฐ์นํ ๊ฐ์ ์ธ๋ก ์ค ๊ฐ์ฅ ํฐ ๊ฐ๊ณผ ๊ฐ๋ก ์ค ๊ฐ์ฅ ํฐ ๊ฐ์ ๊ตฌํ์ฌ ๊ณฑํ ๊ฐ์ ๋ฆฌํด
์์ฑ ์ฝ๋
class Solution {
public int solution(int[][] sizes) {
int answer = 0;
int maxC=0, maxR=0;
for(int i=0; i<sizes.length; i++){
if(sizes[i][1] < sizes[i][0]){
int temp = sizes[i][0];
sizes[i][0] = sizes[i][1];
sizes[i][1] = temp;
}
maxC = maxC < sizes[i][0] ? sizes[i][0] : maxC;
maxR = maxR < sizes[i][1] ? sizes[i][1] : maxR;
}
System.out.printf("%d %d", maxC, maxR);
return maxC*maxR;
}
}
๋์์ด ๋์ จ๋ค๋ฉด ์ข์์ ๋๋ฌ์ฃผ์ธ์๐