Data Structures & AlgorithmsVery hardCodeforces Div 2 · ICPC regional
Array A = [2, 2, 4, 4, 1, 5, 2, 3, 1]. 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. 15
- B. 5
- C. 3
- D. 2
Correct answer: B. 5
The longest strictly increasing subsequence has length 3, and there are 5 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
- Undirected weighted graph on vertices A, B, C, D, E; its edges, in this listed order, are: B–D (7), A–D (7), C–D (9), D–E (3), A–C (2)…
- Directed weighted graph on vertices A, D, B, F, C (source A, target C) with edges: A→D (4); A→B (7); B→D (-6); D→C (3); B→C (1); A→C (12)…
- Directed acyclic graph on vertices A, B, C, D, E with edges A→D, A→C, D→B, D→C. Among all topological orderings (every edge goes from…
- Words ['b', 'b', 'b', 'c', 'cbca', 'aca'] are inserted in this order into an empty trie with one node per character, shared prefixes…
- Connected undirected weighted graph on vertices A, B, C, D, E, F with edges A–D (5), B–D (7), B–F (13), C–D (11), D–E (11), D–F (12), E–F…
- Directed graph on vertices A, B, C, D, E, F, G with edges E→F, C→G, B→E, E→D, E→G, C→E, F→D, C→A, D→A, F→E. How many strongly connected…