[프로그래머스/C++] 주식가격

mani·2023년 4월 16일
0
post-custom-banner

주식가격

#include <string>
#include <vector>

using namespace std;

vector<int> solution(vector<int> prices) {
    vector<int> answer;
    int cnt = 0;
    
    while(cnt < prices.size()-1){
        int ans = 0;
        for(int i=1;i<prices.size()-cnt;i++){
            if(prices.at(cnt)>prices.at(cnt+i)){
                ans = i;
                break;
            }
            ans = i;
        }
        answer.push_back(ans);
        cnt++;
    }
    answer.push_back(0);
    return answer;
}
profile
log
post-custom-banner

0개의 댓글