Data Structures & AlgorithmsHardGATE CS · ICPC regional
What is the length of the longest strictly increasing subsequence (not necessarily contiguous) of [3, 7, 4, 1, 8, 5, 6, 2, 9]?
- A. 5
- B. 4
- C. 2
- D. 3
Correct answer: A. 5
Patience sorting maintains the smallest possible tail of each length; the answer is the number of piles. The longest decreasing subsequence, or the longest contiguous increasing run, is a different quantity.
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
- What is the length of the longest strictly increasing subsequence (not necessarily contiguous) of [13, 9, 11, 2, 6, 4, 7, 10, 1, 5, 8, 12…
- What is the length of the longest strictly increasing subsequence (not necessarily contiguous) of [9, 3, 1, 8, 13, 6, 2, 5, 10, 14, 11, 7…
- What is the length of the longest strictly increasing subsequence (not necessarily contiguous) of [2, 1, 6, 5, 10, 4, 7, 9, 3, 11, 8]?
- What is the length of the longest strictly increasing subsequence (not necessarily contiguous) of [3, 12, 1, 13, 4, 2, 14, 11, 10, 6, 8…
- What is the length of the longest strictly increasing subsequence (not necessarily contiguous) of [11, 4, 12, 7, 3, 2, 13, 8, 6, 14, 1, 5…
- Using unit-cost insertions, deletions and substitutions, what is the minimum number of operations needed to turn the string 'bcacba' into…