[Programmers] 주식가격

Time Lapse :9min 0sec

solution.cpp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <vector>

using namespace std;

vector<int> solution(vector<int> prices) {
vector<int> answer(prices.size());
int size = prices.size()-1;
for(int i=0;i<=size;i++){
answer[i] = size - i;
for(int j=i+1;j<=size;j++){
if(prices[j]<prices[i]){
answer[i] = j-i;
break;
}
}
}
return answer;
}
Author: Song Hayoung
Link: https://songhayoung.github.io/2020/07/30/PS/Programmers/stockPrice/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.