Question d’entretien chez Google

Maximum rectangular area under a histogram.

Réponses aux questions d'entretien

Utilisateur anonyme

28 déc. 2013

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

Utilisateur anonyme

12 janv. 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.

Utilisateur anonyme

29 mars 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.