Data Structures & AlgorithmsVery hardICPC regional · Product Company SDE

Problem: Count the longest increasing subsequences (subsequences of maximum length, strictly increasing) of [1, 3, 5, 4, 7]. Two index sets count as different even if the values match.

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

Correct answer: B. 2

Track both the LIS length ending at each index and how many ways achieve it. Counting only one optimal subsequence, or all increasing subsequences, gives a different count.

More Coding Interview Problems questions

Exams that ask this topic