力扣 739. 每日温度 单调栈
发布日期:2021-11-05 06:59:27 浏览次数:16 分类:技术文章

本文共 346 字,大约阅读时间需要 1 分钟。

在这里插入图片描述
思路:单调栈的简单变形。

class Solution {
public: vector
dailyTemperatures(vector
& T) {
stack
s; int siz=T.size(); vector
ans(siz); for(int i=0;i
T[s.top()]) ans[s.top()]=i-s.top(),s.pop(); s.push(i); } return ans; }};

转载地址:https://blog.csdn.net/xiji333/article/details/107944033 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:力扣 面试题 17.21. 直方图的水量 dp/双指针/单调栈
下一篇:力扣 1441. 用栈操作构建数组 栈

发表评论

最新留言

表示我来过!
[***.240.166.169]2024年03月20日 18时22分48秒