[Programmers] : 스택/큐 :: 주식가격

package org.kyhslam;

import java.util.Arrays;

public class stack03 {

    public static 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++) {
                answer[i]++;

                if(prices[i] > prices[j]){
                    break;
                }
            }
        }


        System.out.println(Arrays.toString(answer));

        return answer;
    }

    public static void main(String[] args) {
        int[] p = {1,2,3,2,3};
        // 4,3,1,1,0
        solution(p);
    }
}

댓글

Designed by JB FACTORY