Largest Rectangle Area after drawing each boundary
Anonymous User
1364

Q: You have a rectangle of width w and height h. You will start to draw boundaries. The number of boundaries is given by the length of the given array, distance.

isVertical[i] represents whether or not i-th boundary is vertical or not. 1 means vertical and 0 means horizontal.

distance[i] tells the distance between your boundary and the rectangle. In case of a horizontal boundary,

it represents the distance from the bottom of your rectangle, and in case of a vertical boundary, it represents the distance from the left of your rectangle.

You need to return the largest areas of your rectangle as an array after drawing each of your boundaries.

ex) w = 4, h = 4, isVertical = [0,1], distance = [3,1]
After drawing the first boundary, the largest possible rectangle area is 12.
After drawing the second boundary, the largest possible rectangle area is 9.
You are not given a new rectangle for each boundary. You draw boundaries on the same rectangle.

You should return [12, 9].

Any ideas?

Comments (2)