This can be solved in using a simple stack algorithm.
– Scan from left to right.
– Add to the stack when height is going up.
– Otherwise, this marks the end of a (previous) taller rectangle, which is checked for area.
My implementation is in git and below: