
정수 start와 end가 주어질 때, start에서 end까지 1씩 감소하는 수들을 차례로 담은 리스트를 return하도록 solution 함수를 완성해주세요.
end ≤ start ≤ 50| start | end | result |
|---|---|---|
| 10 | 3 | [10, 9, 8, 7, 6, 5, 4, 3] |
입출력 예 #1
import java.util.*;
class Solution {
public int[] solution(int start, int end) {
List<Integer> answer = new ArrayList<>();
for (int i = start; i >= end; i--) {
answer.add(i);
}
return answer.stream().mapToInt(i->i).toArray();
}
}