class Solution {
public int[] solution(int[] num_list) {
int[] answer = {};
return answer;
}
}
import java.util.*;
class Solution {
public int[] solution(int[] num_list) {
List<Integer> list = new ArrayList<>();
Arrays.sort(num_list);
for (int i = 0; i < 5; i++) {
list.add(num_list[i]);
}
int[] answer = new int[list.size()];
for (int i = 0; i < list.size(); i++) {
answer[i] = list.get(i);
}
return answer;
}
}
import java.util.Arrays;
class Solution {
public int[] solution(int[] num_list) {
int[] answer = new int[5];
Arrays.sort(num_list);
for (int i = 0; i < answer.length; i++) {
answer[i] = num_list[i];
}
return answer;
}
}
import java.util.Arrays;
class Solution {
public int[] solution(int[] num_list) {
Arrays.sort(num_list);
return Arrays.copyOfRange(num_list, 0, 5);
}
}
copyOfRange(원본 배열, 시작 인덱스, 끝 인덱스);