GaGe

[프로그래머스] 주식가격 - java 본문

알고리즘/[2020] 프로그래머스

[프로그래머스] 주식가격 - java

Sorrel 2020. 4. 12. 14:26
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; j<prices.length;j++){ 
                if(prices[i]>prices[j] || j==prices.length-1){ 
                    answer[i]=j-i; 
                    break; 
                } 
            } 
        } 
        return answer; 
    } 
}
Comments