Data Structures & AlgorithmsHardCodeforces Div2 B-D · ICPC regional

What is the sum over all subarrays of [3, 1, 2, 4] of the minimum element of each subarray?

  1. A. 17
  2. B. 30
  3. C. 18
  4. D. 40

Correct answer: A. 17

Each element is the minimum of (its left span) times (its right span) subarrays, computed with a monotonic stack. Summing over all subarrays by brute force gives the same total.

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

Exams that ask this topic