Data Structures & AlgorithmsVery hardCodeforces Div2 D · ICPC regional

For the array [1, 3, 5, 4, 7, 2, 2, 8, 6, 9], how many DIFFERENT subsequences (chosen by index) are strictly increasing AND have the maximum possible length?

  1. A. 6
  2. B. 2
  3. C. 143
  4. D. 1

Correct answer: B. 2

Keep a second array counting how many longest increasing subsequences end at each index, and add counts when a predecessor gives the same best length. The length alone does not answer a count question, and counting every increasing subsequence includes short ones.

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

Exams that ask this topic