YJ의 새벽
프로그래머스(0) - 최댓값 만들기(2) [JAVA] 본문
import java.util.Arrays;
class Solution {
public int solution(int[] numbers) {
int answer = 0;
Arrays.sort(numbers);
int a = numbers[numbers.length-2] * numbers[numbers.length-1];
int b = numbers[0] * numbers[1];
if ( a > b ) {
answer = a;
}else {
answer = b;
}
return answer;
}
}
'코딩테스트연습 > 프로그래머스' 카테고리의 다른 글
프로그래머스(0) - 인덱스 바꾸기 [JAVA] (0) | 2024.03.13 |
---|---|
프로그래머스(0) - 문자열 정렬하기(1) [JAVA] (0) | 2024.03.13 |
프로그래머스(0) - 직각삼각형 출력하기 (0) | 2024.03.13 |
프로그래머스(0) - 가장 큰 수 찾기 (0) | 2024.03.13 |
프로그래머스(0) - 암호 해독 (0) | 2024.03.13 |
Comments