728x90
+++큰 순으로 3개
--작은순으로 2개 & +큰순으로 1개
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | public int solution(int[] A) { // write your code in Java SE 8 Arrays.sort(A); int leng = A.length; // for(int a : A ) System.out.println(a); int mmp = A[0]*A[1]*A[leng-1]; int ppp = A[leng-1]*A[leng-2]*A[leng-3]; return (mmp>ppp)?mmp:ppp; } | cs |
'알고리즘 풀이 > Codility' 카테고리의 다른 글
Codility - Triangle (Sorting) (0) | 2019.12.13 |
---|---|
Codility - Distinct (Sorting) (0) | 2019.12.13 |
codility - CountDiv (Prefix Sums) (0) | 2019.12.13 |
codility - MinAvgTwoSlice (Prefix Sums) (0) | 2019.12.13 |
codility - GenomicRangeQuery (Prefix Sums) (0) | 2019.12.10 |