>_
largest_rectangle_area.java
Java 25.0
Not run yet

+ 8 hidden

Input
heights = [2, 4, 5, 3, 1, 3]
Expected
9

The bars 4, 5, 3 at indices 1 to 3 are all at least 3 tall, so a rectangle of height 3 and width 3 fits: 3 × 3 = 9. The tallest bar alone gives only 5.