Data Structures & AlgorithmsHard

How many contiguous subarrays of 1 2 1 1 3 1 2 have a STRICT majority element, meaning some value occurs more than half the time in the subarray?

  1. A. 27
  2. B. 19
  3. C. 12
  4. D. 8

Correct answer: B. 19

A strict majority needs more than half of the elements, so a tie (exactly half) does not qualify. Counting ties as majorities, dropping singletons, or counting constant blocks each change the total.

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

Exams that ask this topic