Data Structures & AlgorithmsHardGATE CS · TCS NQT

In the binary row [1, 1, 0, 1, 1, 1] treated as a histogram of height 1, what is the largest rectangle area?

  1. A. 4
  2. B. 3
  3. C. 2
  4. D. 5

Correct answer: B. 3

With every bar height 1, the largest rectangle is simply the longest run of ones, which is three here. The monotonic stack reproduces this, and summing all ones is a different quantity.

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

Exams that ask this topic