주식가격

108번뇌·2020년 9월 27일
0

풀었음.

https://school.programmers.co.kr/learn/courses/30/lessons/42584

#include <string>
#include <vector>
 
using namespace std;

int compare(int a, int b)
{
    if (a<=b)
        return 1;
    else
        return 0;
}
 
vector<int> solution(vector<int> prices) {
    vector<int> answer;
    for(int i=0; i < prices.size()-1; i++)
    {
      //  if(i == prices.size()){answer.push_back(0); return answer;}
        int Count = 0;
        for(int j = i+1; j<prices.size() ; j++ )
        {
            Count = Count + compare(prices[i],prices[j]);
            if(0==compare(prices[i], prices[j])){ Count++; break;}
        }
        answer.push_back(Count);
    }
     answer.push_back(0);
    return answer;
}

profile
내일 아침 눈을 떳을 때, '기대되는 오늘 하루를 만들기 위해' 나는 오늘도 생각하고 고민한다.

0개의 댓글