Data Structures & AlgorithmsHardCodeforces Div2 C · GATE CS

For [4, 1, 3, 7, 2], what is the maximum over index pairs i < j of min(a[i], a[j]) times (j - i)?

  1. A. 13
  2. B. 10
  3. C. 35
  4. D. 12

Correct answer: D. 12

This is the 'largest rectangle' of container type: use a two-pointer scan that always moves the smaller side. Checking all pairs confirms the maximum.

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

Exams that ask this topic