Data Structures & AlgorithmsModerate

How many contiguous subarrays of length at least 2 of 5 1 2 1 6 2 have a MAXIMUM element strictly greater than the sum of all their other elements?

  1. A. 11
  2. B. 19
  3. C. 0
  4. D. 2

Correct answer: A. 11

The condition compares the maximum with the total of the rest, which is sum minus maximum. Using ≥, comparing with the full sum, or the opposite inequality each classify subarrays differently.

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

Exams that ask this topic