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?
- A. 7
- B. 6
- C. 9
- 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
- Problem: Find the minimum path sum from the top to the bottom of the triangle [[2], [3, 4], [6, 5, 7], [4, 1, 8, 3]], moving to an…
- Problem: The message "2261" is decoded by mapping 1→A, ..., 26→Z. Each decoding splits the digits into groups of one or two digits, each…
- Problem: 23 people stand in a circle numbered 1 to 23. Starting at person 1, every second person is eliminated (counting around the…
- Problem: Eight cards labelled 1 to 8 are in a row. A perfect out-shuffle splits the deck into two equal halves (1–4 and 5–8) and…
- Problem: Lamps 1 to 20 are all off. For each pass i = 1 to 20, every lamp whose number is a multiple of i is toggled. How many lamps are…
- Problem: Count integers from 1 to 100 that are divisible by 3 or by 5 but not by 15.