카테고리 없음
프로그래머스>스택/큐>주식가격
연주우
2021. 5. 1. 23:48
import java.util.Arrays;
class Solution {
public int[] solution(int[] prices) {
int[] answer = new int [prices.length];
for(int i=0; i<prices.length; i++)
{
for(int j= i+1; j<prices.length; j++)
{
if(prices[i]>prices[j])
{
answer[i]= j-i;
break;
}
/*
if(j == answer.length -1)
answer [i] = j-i;
*/
}
}
System.out.println(Arrays.toString(answer));
return answer;
}
}