Data Structures & AlgorithmsHard

How many contiguous subarrays of 1 3 2 5 4 6 1 2 of length at least 3 have exactly one interior strict local maximum (a position strictly inside the subarray that is larger than both its neighbours)?

  1. A. 18
  2. B. 10
  3. C. 11
  4. D. 9

Correct answer: B. 10

Count interior strict peaks within each block, so the neighbours are those inside the block only. Using at-least-one, non-strict peaks, or zero peaks each change the set.

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

Exams that ask this topic