
class Solution {
public:
vector<int> dailyTemperatures(vector<int>& temperatures) {
int n = temperatures.size();
vector<int> answer(n,0);
stack<int> stk;
stk.push(0);
for(int i = 0;i<n;i++){
while(!stk.empty()&&temperatures[i]>temperatures[stk.top()]){
answer[stk.top()] = i-stk.top();
stk.pop();
}
stk.push(i);
}
return answer;
}
};

7793





