Amazon Interview Question

Given a histogram, find a rectangular box(non empty) that will cover maximum area.

Interview Answer

Anonymous

Nov 12, 2011

Given [1,6,6,1], a vertical rectangular box enclosing both the 6's will have an area of 2*6=12. Also in the case of [4,6,6,4], Horizontal box (square) starting from the first bar, enclosing all the bars will have an area of 4*4=16 making it the maximum