Programmers - 주식가격

문제 링크

Java 풀이

class Solution {
    public int[] solution(int[] prices) {
        int[] answer = new int[prices.length];        
        for(int index = 0; index < prices.length; index++){
            int second = 0;
            for(int index2 = index + 1; index2 < prices.length; index2++){
                second = second + 1;
                if( prices[index] > prices[index2] ) break;                
            }
            answer[index] = second;
        }
        return answer;
    }
}