Billboard in the Skyline
hardA city block is a row of buildings, each one unit wide, with heights given by heights. An advertiser wants to mount the largest possible rectangular billboard flat against the block: it must span consecutive buildings and cannot rise above any building it spans.
Return the maximum billboard area: the largest value of width × min_height over all runs of consecutive buildings.
Example 1
in heights = [2, 1, 5, 6, 2, 3]
out 10
Buildings 5 and 6 support a 2-wide, 5-tall billboard: area 10.
Example 2
in heights = [2, 4]
out 4
Either the 4 alone (4) or both at height 2 (4).
Example 3
in heights = [1, 1, 1, 1]
out 4
The full block at height 1.
Constraints
- · 1 <= len(heights) <= 10^5
- · 0 <= heights[i] <= 10^4
solution.py● loading python…
test results
Hit ▶ Run to test your code against the visible cases.