单调栈模板
2023-02-18 16:41:52 时间
单调栈算法总结
链接:https://leetcode-cn.com/problems/largest-rectangle-in-histogram/
84.柱状图中最大的矩形
int SingleStack(vector<int>& heights) {
stack<int> single_stack;
int res=0;
for(int i=0;i<heights_new.size();i++){
while(heights[single_stack.top()]>heights_new[i])
{
int h=heights[single_stack.top()]; //取第一个作为高
single_stack.pop();
int left=single_stack.top(); //取第二个计算宽
int right=i;
res=max(res, (right-left-1)*h);
}
single_stack.push(i);
}
return res;
}
相关文章
- 接口测试第10讲:基pytest框架requests自动化测试
- 请求接口时出现 Status (blocked:other)
- Laravel 批量更新
- Laravel orWhere条件
- Mac iTerm ssh 连接服务器
- crontab 脚本测试demo
- Nginx 查看接口请求内容
- 记录一次 laravel 项目队列拥堵的问题
- kafka 入门
- 使用 supervisor 来管理 kafka进程
- Failed to get D-Bus connection: Operation not permitted
- laravel 中使用 Hash::make() 对用户密码进行加密
- 并发情况下产品超卖
- laravel 中字段格式处理
- 开发中遇到的越权问题
- ES 简单操作指令
- shell 脚本提示权限不够的几种解决方式
- laravel 之 Unit 单元测试
- yii 配置文件根据模式分类
- ssh通过证书登陆服务器