문제
내가 작성한 정답
Array
class Solution {
public int[] solution(int[] num_list, int n) {
int[] answer = new int[num_list.length-n+1];
for(int i=0; i< num_list.length-n+1; i++){
answer[i] = num_list[n+i-1];
}
return answer;
}
}
StreamAPI
import java.util.stream.*;
class Solution {
public int[] solution(int[] num_list, int n) {
return IntStream.range(n-1,num_list.length)
.map(i->num_list[i]).toArray();
}
}
다른 사람들의 정답
import java.util.*;
class Solution {
public int[] solution(int[] num_list, int n) {
int[] a= Arrays.copyOfRange(num_list, n-1, num_list.length);
return a;
}
}
Share article