Data Structures & AlgorithmsHardAmazon OA · Stacks

What is the area of the largest rectangle in a histogram with bar heights [3, 6, 5, 7, 4, 8, 1, 0, 6] and unit width?

  1. A. 20
  2. B. 18
  3. C. 24
  4. D. 28

Correct answer: A. 20

The five bars from the 2nd to the 6th all have height at least 4, giving 4 x 5 = 20; the bars 6, 5, 7 alone give only 15.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic