Data Structures & AlgorithmsHard

In the array [2, 7, 3, 7, 1, 4], how many contiguous subarrays have their LEFT-most element equal to the maximum of the subarray (ties allowed)?

  1. A. 9
  2. B. 12
  3. C. 11
  4. D. 13

Correct answer: B. 12

The condition is on the first element only, but it must dominate every other element of the subarray. Requiring a strictly larger value excludes ties, and checking the minimum or the right end measures other properties.

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

Exams that ask this topic