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