文章
99
粉丝
120
获赞
8
访问
92.5k
class Solution {
public:
vector<int> dailyTemperatures(vector<int>& temperatures) {
int n = temperatures.size();
vector<int>ans(n);
stack<int>s;
for(int i = 0; i < n; i++){
while(s.size() && temperatures[i]>temperatures[s.top()]){
int pre = s.top() ;
ans[pre] = i-pre;
s.pop();
}
s.push(i);
}
return ans;
}
};
登录后发布评论
暂无评论,来抢沙发