Data Structures & AlgorithmsVery hardCodeforces Div 2 · ICPC regional

Array A = [2, 1, 2, 3, 3, 4, 1, 5]. An increasing subsequence is chosen by INDEX positions i1 < i2 < … with A[i1] < A[i2] < … (strictly increasing). How many index sets give an increasing subsequence of the maximum possible length?

  1. A. 2
  2. B. 1
  3. C. 11
  4. D. 5

Correct answer: A. 2

The longest strictly increasing subsequence has length 5, and there are 2 index sets achieving it. Counting distinct value sequences merges equal choices, which is the trap here.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic