Dodomeki
Sign in

103. Largest Rectangle in Histogram

Hard

A histogram has adjacent bars of width 1, with heights in alturas. Return the largest area of a rectangle that can be formed entirely within the bars. The area may use one bar or several consecutive bars.

Example 1
Input: alturas = [2, 1, 5, 6, 2, 3]
Output: 10
Explanation: The bars with heights 5 and 6 form a rectangle with height 5 and width 2.
Example 2
Input: alturas = [3, 3, 3]
Output: 9
Constraints
  • 0 <= alturas.length <= 10^5
  • 0 <= alturas[i] <= 10^4
ArraysStack
Caso 1
alturas =
[2,1,5,6,2,3]
Expected =
10
Caso 2
alturas =
[3,3,3]
Expected =
9

Run checks these 2 cases. Submit runs all 7, including hidden ones.