Data Structures & AlgorithmsModerate

How many index pairs i < j in 2 3 1 4 5 2 6 have the closed block A[i..j] strictly increasing (with j > i)?

  1. A. 5
  2. B. 15
  3. C. 4
  4. D. 6

Correct answer: A. 5

The whole block must be strictly increasing, not just its endpoints, so each step inside has to be checked. Comparing only the endpoints, allowing equal neighbours, or counting adjacent steps each measure different sets.

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

Exams that ask this topic