#include <string>
#include <vector>
#include <stack>
usingnamespacestd;vector<int>solution(vector<int>prices){vector<int>answer(prices.size());stack<int>s;for(inti=0;i<prices.size();i++){// if stack is not empty and price is not going downwhile(!s.empty()&&prices[s.top()]>prices[i]){answer[s.top()]=i-s.top();// current time - top of stacks.pop();}s.push(i);}// while문으로 stack에 남아있는 값 처리 while(!s.empty()){answer[s.top()]=prices.size()-1-s.top();// prices.size() - 1 = end time s.pop();}returnanswer;}