Data Structures & AlgorithmsHardGATE CS · ICPC regional

What is the largest rectangular area in a histogram with bar heights 6, 2, 5, 4, 5, 1, 6 (each bar has width 1)?

  1. A. 12
  2. B. 13
  3. C. 15
  4. D. 18

Correct answer: A. 12

The best rectangle uses the three middle bars 5, 4, 5 at height 4, giving 12. Bars of height 6 at the ends only give 6 alone.

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

Exams that ask this topic