Data Structures & AlgorithmsVery hardCodeforces Div 2 · ICPC regional
Array A = [2, 1, 2, 3, 3, 4, 1, 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. 2
- B. 1
- C. 11
- D. 5
Correct answer: A. 2
The longest strictly increasing subsequence has length 5, and there are 2 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
- Distinct words ['bb', 'c', 'b', 'ac', 'cab'] are inserted into an empty trie (one node per character, shared prefixes share nodes, and a…
- Connected undirected graph on vertices A, B, C, D, E, F, G, H with edges A–D (1), A–H (1), B–D (1), B–E (1), B–F (1), B–H (1), C–F (1)…
- Connected undirected weighted graph on vertices A, B, C, D, E, F with edges A–C (5), A–F (7), B–E (5), C–E (9), C–F (20), D–E (20), D–F…
- Directed acyclic graph on vertices A, B, C, D, E, F, G with edges F→D, F→C, A→C, A→E, A→G, D→E, E→B. Among all topological orderings…
- Strings a = "ccca" and b = "cbca". The edit distance allows insert, delete and substitute, each costing 1 (the standard Levenshtein…
- Tree with vertices 0 to 8, root 0, edges 0–1, 1–2, 1–3, 1–4, 2–5, 2–6, 6–7, 5–8 (parent–child). Vertex weights (vertex:weight) 0:11, 1:10…