Mono-descreasing stack
class Solution {
public:
vector<int> dailyTemperatures(vector<int>& temperatures) {
vector<int> res(temperatures.size(), 0);
stack<int> st;
for (int i = 0; i < temperatures.size(); i++) {
while (!st.empty() && temperatures[st.top()] < temperatures[i]) {
res[st.top()] = i - st.top();
st.pop();
}
st.push(i);
}
return res;
}
};
[73,74,75,71,69,72,76,73]