import java.util.*;
import java.util.stream.Collectors;
class Solution {
public int[] solution(int[] prices) {
List<Integer> answer = new ArrayList<>();
Queue<Integer> queue = new LinkedList<>(Arrays.stream(prices).boxed().collect(Collectors.toList()));
while (!queue.isEmpty()){
int first = queue.poll();
int time = 0;
for (int a : queue){
time++;
if(first > a){
break;
}
}
answer.add(time);
}
return answer.stream().mapToInt(i -> i).toArray();
}
}
뽑은 주식 가격을 반복문을 통해 비교하면서 시간은 ++해주다가
if → 떨어지는 시점이 생기는 순간 break을 통해 반복문 탈출.
배열 변환 후 반환.