Data Structures & AlgorithmsHardGATE CS · ICPC regional

In the sequence [1, 3, 5, 2, 4, 6], how many strictly increasing subsequences have the maximum possible length (count by index positions)?

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

Correct answer: A. 3

Keep for each index both the longest increasing subsequence ending there and the number of ways to achieve it, then sum the counts at the maximal length. The LIS length alone (here 4) is not the count asked for.

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

Exams that ask this topic