Data Structures & AlgorithmsHard

How many contiguous subarrays of 4 1 3 2 6 1 have a sum STRICTLY greater than the sum of the elements outside them?

  1. A. 0
  2. B. 8
  3. C. 13
  4. D. 9

Correct answer: B. 8

Outside sum equals total minus block sum, so the test is block sum above half the total. Using ≥, comparing with the whole total, or the opposite inequality each change the count.

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

Exams that ask this topic