Data Structures & AlgorithmsHardGATE CS · ICPC regional

What is the area of the largest rectangle containing only 1s in the binary matrix whose rows are 1101, 1111, 0111 and 1110?

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

Correct answer: B. 6

Treat each row as the base of a histogram whose heights count consecutive 1s above it, then apply the largest-rectangle-in-histogram stack to each row.

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

Exams that ask this topic