๐ก ์ข์ ์ฝ๋
๊ฐ๋จํ๊ฒ ๋ฉ์๋๋ฅผ ์ด์ฉํด์ ์์ - ๋ ๊ฐ์ ์ง์ ํด์ค์ ์ถ๋ ฅํ ์ ์๋ค.
๐ฌ Arrays.copyOfRange(๋ฐฐ์ด , ์์, ๋);
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;
}
}
๐ก for ๋ฌธ์ ์ด์ฉํด์ ๋์ ๋ฐฐ์ด์ ์ฝ์ ํด์ค๋ค.
n ์ ์ธ๋ฑ์ค ๊ฐ์ผ๋ก ์ธ์์์ผ์ฃผ๋ ค๋ฉด n - 1 ์ ํด์ค์ผ ํ๋ค !!
import java.util.Arrays;
import java.util.ArrayList;
class Solution {
public ArrayList <Integer> solution(int[] num_list, int n) {
ArrayList <Integer> answer = new ArrayList <Integer>();
for (int i = n-1; i < num_list.length; i++){
answer.add(num_list[i]);
}
return answer;
}
}