Data Structures & AlgorithmsModerateGATE CS · ICPC regional
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]?
- A. 4
- B. 6
- C. 3
- D. 5
Correct answer: D. 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 [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…
- Using unit-cost insertions, deletions and substitutions, what is the minimum number of operations needed to turn the string 'bcccb' into…
- Using unit-cost insertions, deletions and substitutions, what is the minimum number of operations needed to turn the string 'bbabaac' into…
- Using unit-cost insertions, deletions and substitutions, what is the minimum number of operations needed to turn the string 'bbbc' into…