//LV2. 주식가격
public static int[] solution_stock_price(int[] prices) {
int[] answer = new int[prices.length];
for(int i=0;i<prices.length;i++){
int cnt = 0;
for(int j=i+1;j<prices.length;j++){
cnt++;
if(prices[j] < prices[i]) break;
}
answer[i] = cnt;
}
return answer;
}
'Algorithm > Programmers' 카테고리의 다른 글
[Programmers] LV2. 모음사전 (0) | 2023.03.20 |
---|---|
[Programmers] LV2.n^2배열 자르기 (0) | 2023.03.20 |
[Programmers] LV2. 예상 대진표 (0) | 2023.03.17 |
[Programmers] LV2.이진변환 반복하기 (0) | 2023.03.17 |
[Programmers] LV2. 타켓넘버 (0) | 2023.03.17 |