Data Structures & AlgorithmsVery hardCodeforces Div2 D · ICPC regional

The binary matrix [[1, 0, 1, 1, 0], [1, 1, 1, 1, 0], [1, 1, 1, 1, 1], [1, 0, 0, 1, 0]] is given. What is the area of the largest rectangle consisting only of 1s?

  1. A. 4
  2. B. 6
  3. C. 8
  4. D. 14

Correct answer: C. 8

Turn each row into a histogram of consecutive 1s above it, then apply the histogram-rectangle stack to each row. The largest square of ones is a different (usually smaller) quantity.

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

Exams that ask this topic