Data Structures & AlgorithmsHard

How many contiguous subarrays of 2 4 6 4 2 8 have an AVERAGE exactly equal to the average of the whole array?

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

Correct answer: A. 1

Compare averages as exact fractions, sum over length, rather than as sums; equal averages are a different condition from equal sums. Strict comparison or raw sums each answer a different question.

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

Exams that ask this topic