LargestRectangleArea
来源:互联网 发布:淘宝古董钟表 编辑:程序博客网 时间:2024/06/11 08:54
public class Solution { public int largestRectangleArea(int[] height) { int len = height.length; Stack<Integer> s = new Stack<Integer>(); int maxArea = 0; for(int i = 0; i <= len; i++){ int h = (i == len ? 0 : height[i]); if(s.isEmpty() || h >= height[s.peek()]){ s.push(i); }else{ int tp = s.pop(); maxArea = Math.max(maxArea, height[tp] * (s.isEmpty() ? i : i - 1 - s.peek())); i--; } } return maxArea; }}
阅读全文
0 0
- LargestRectangleArea
- 《leetCode》:largestRectangleArea
- leetcode——largestRectangleArea
- 互联网服务器架构
- 取石子(一)
- BZOJ 3881: [Coci2015]Divljak
- 本地配置多个tomcat应用
- IDEA搭建SSM框架 以及环境配置
- LargestRectangleArea
- python中对象序列化及tensorflow的命令行参数解析
- PX4飞控之添加地面站参数
- Bellman-ford算法求解单源点最短路径初始版本
- java hashcode() 与 equals()
- Android 双屏异显
- Learining TypeScript (一) TypeScript 简介
- c++实现链表的基本操作
- 10分钟让你明白MySQL是如何利用索引的