height
, left
, right
, and max_area
arrays with appropriate starting values.height
array based on the continuity of '1's from the top.
b. Update left
array based on the previous left
value and the current left boundary.
c. Update right
array in a right-to-left manner based on the previous right
value and the current right boundary.
d. Calculate the area for each point using height
, left
, and right
arrays and update max_area
if a larger area is found.max_area
as the largest rectangle area.