Data Structures & AlgorithmsVery hardICPC regional · Codeforces Div2 D

Problem: The longest bitonic subsequence (first strictly increasing, then strictly decreasing, either part may be empty) of [1, 11, 2, 10, 4, 5, 2, 1] has what length?

  1. A. 7
  2. B. 6
  3. C. 9
  4. D. 5

Correct answer: B. 6

For each index add LIS ending there and LDS starting there, minus 1 for the shared peak: e.g. 1, 2, 10, 5, 2, 1 or 1, 11, 10, 5, 2, 1 → 6. Forgetting the − 1 gives 7, adding the global LIS (4) and LDS (5) without a shared peak gives 9, and the LDS alone is 5.

More Coding Interview Problems questions

Exams that ask this topic