Data Structures & AlgorithmsVery hardCodeforces Div 2 · ICPC regional
Array A = [3, 4, 4, 1, 1, 4, 5, 5]. An increasing subsequence is chosen by INDEX positions i1 < i2 < … with A[i1] < A[i2] < … (strictly increasing). How many index sets give an increasing subsequence of the maximum possible length?
- A. 3
- B. 10
- C. 2
- D. 29
Correct answer: B. 10
The longest strictly increasing subsequence has length 3, and there are 10 index sets achieving it. Counting distinct value sequences merges equal choices, which is the trap here.
Practise more Trees, Graphs, Recursion and Dynamic Programming questionsTrees, Graphs, Recursion and Dynamic Programming: notes and key points
More Trees, Graphs, Recursion and Dynamic Programming questions
- Directed graph on vertices A, B, C, D, E, F, G with edges E→B, D→A, C→A, B→E, C→B, F→A, E→D, G→B, B→F, F→G. How many strongly connected…
- Keys [20, 43, 1, 35, 37, 18, 49] are inserted, in this order, into an empty AVL tree using the standard rebalancing (left, right…
- On an 7 × 7 chessboard with rows and columns numbered 0 to 6, a knight starts at (4, 5) and must reach (6, 1) (as (row, column)). A knight…
- Distinct words ['c', 'bcb', 'cccb', 'ba', 'bcba', 'bb', 'ac'] are inserted into an empty trie (one node per character, shared prefixes…
- Consider the recursive function def f(n): if n < 3: return 1; return f(n-1) + f(n-3). Evaluate f(8) and count every invocation of f…
- Directed graph on vertices A, B, C, D, E, F, G with edges F→B, E→B, G→E, C→G, E→D, F→D, F→C, F→E, G→F, C→B, G→A. How many strongly…