Pregunta de entrevista de Google

Maximum rectangular area under a histogram.

Respuestas de entrevistas

Anónimo

28 dic 2013

the histogram is given as list example {2,2,4,2,1,1,1}

Anónimo

12 ene 2014

For each distinct value (1,2,4) pass initial array trying to find maximum continious region covering this value (area is value * region-length). Pass complexity is O(N^2). Copied list could be sorted (N log N) in order to get distinct values.

Anónimo

29 mar 2014

It is similar to grouping items in a sorted array. Keep walking along the array and everytime the height changes, look back to see how many had the same height and compute area. Keep track of max area.