Data Structures & AlgorithmsHardGATE CS · competitive programming

What is the area of the largest rectangle in the histogram with bar heights [2, 4, 2, 1, 6, 5, 5]?

  1. A. 12
  2. B. 15
  3. C. 16
  4. D. 10

Correct answer: B. 15

The best rectangle spans the bars 6, 5, 5 with width 3 and height 5, giving 15. A 16 would need four consecutive bars of height at least 4, and the height-1 bar breaks that run.

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

Exams that ask this topic