class Solution {
public int[] solution(int[] arr, int[][] intervals) {
int[] answer = {};
return answer;
}
}
해결법
방법 1
import java.util.ArrayList;
class Solution {
public int[] solution(int[] arr, int[][] intervals) {
ArrayList<Integer> list = new ArrayList<>();
for (int i = 0; i < intervals.length; i++) {
for (int j = intervals[i][0]; j <= intervals[i][1]; j++) {
list.add(arr[j]);
}
}
int[] answer = new int[list.size()];
for (int i = 0; i < list.size(); i++) {
answer[i] = list.get(i);
}
return answer;
}
}
배열 만들기 3 Lv. 0