Data Structures & AlgorithmsHard

How many index triples i < j < k in 2 5 3 8 6 9 4 have A[i] < A[j] < A[k] AND an EVEN total sum?

  1. A. 13
  2. B. 16
  3. C. 7
  4. D. 6

Correct answer: D. 6

Enumerate index triples in order, requiring both strict increases and an even total. Dropping the parity test, relaxing strictness, or dropping the monotone test each give other counts.

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

Exams that ask this topic