Data Structures & AlgorithmsVery hardGATE CS · TCS NQT

The histogram heights [1, 3, 3, 2, 3] describe bars of width 1. What is the area of the largest rectangle that fits under the histogram?

  1. A. 9
  2. B. 8
  3. C. 6
  4. D. 12

Correct answer: B. 8

The height-2 rectangle spanning indices 1 to 4 has width 4 and area 8, which beats every other rectangle; the height-1 rectangle over all five bars has area 5.

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

Exams that ask this topic