#include <string>
#include <string>
#include <vector>
 
using namespace std;
 
vector<int> solution(vector<int> prices) 
{
    vector<int> answer(prices.size(), 0);
 
    for (int i = 0; i < prices.size(); ++i)
    {
        for (int j = i + 1; j < prices.size(); ++j)
        {
            if (prices[i] > prices[j])
            {
                answer[i] = j - i;
 
                break;
            }
 
            else if (j == prices.size() - 1)
                answer[i] = j - i;
        }
    }
 
    return answer;
}
 

문제 설명이 조금 아쉽다.

1. 주식이 떨어졌을 그 시간의 차이만큼 걸린다.

2. 마지막 주식은 5 - 5 하기 때문에 0

 

 

+ Recent posts