less than 1 minute read


0. 들어가면서

스택/큐의 주식가격 문제이다.

1. 문제풀이

1.1 Java

class Solution {
    public int[] solution(int[] prices) {
        int[] answer = new int[prices.length];

        for(int i =0; i<prices.length; i++){
            int temp = prices[i];
            int count = 0;
            for(int j = i+1; j<prices.length; j++){
                count+=1;
                if(prices[i]>prices[j]){
                    break;
                }

            }
            answer[i]=count;
        }
        System.out.println(answer[0]);
        return answer;
    }
}

1.2 Go

CLOSING

나쁘지 않았다.

Leave a comment