84.Largest-Rectangle-in-Histogram

84. Largest Rectangle in Histogram

题目地址

https://www.lintcode.com/problem/largest-rectangle-in-histogram

https://leetcode.com/problems/largest-rectangle-in-histogram/

题目描述

Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the histogram.

Example:
Input: [2,1,5,6,2,3]
Output: 10

代码

Approach #1 Brute Force

Time: O(n^2) Space O(1)

Approach #2: Divide and Conquer

Approach 3: Better Divde and Conquer

Approach 4: Using Stack 单调递增栈

Last updated

Was this helpful?