뒤에서 5등

김윤하·2023년 12월 14일
0

CodingTest

목록 보기
26/27
post-thumbnail

문제 설명

정수로 이루어진 리스트 num_list가 주어집니다. num_list에서 가장 작은 5개의 수를 제외한 수들을 오름차순으로 담은 리스트를 return하도록 solution 함수를 완성해주세요.

제한사항

6 ≤ num_list의 길이 ≤ 30
1 ≤ num_list의 원소 ≤ 100

import java.util.*;

class Solution {
    public int[] solution(int[] num_list) {
        int[] answer = new int[num_list.length - 5];
        Arrays.sort(num_list);
        
        for (int i = 5; i < num_list.length; i++) {
            answer[i - 5] = num_list[i];
        }
        
        return answer;
    }
}

0개의 댓글