Data Structures & AlgorithmsHardGATE CS · Codeforces Div2 C
What is the length of the longest STRICTLY increasing subsequence of [3, 10, 2, 1, 20, 4, 6, 7, 6, 7, 8, 2]?
- A. 5
- B. 6
- C. 4
- D. 7
Correct answer: A. 5
Use the patience-sorting method with bisect_left for strict increase. Using bisect_right (or a ≤ test) allows equal values into the same subsequence, which lengthens the answer for repeated values.
Practise more Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questionsArrays, Strings, Linked Lists, Stacks, Queues and Hashing: notes and key points
More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions
- For the array [1, 3, 5, 4, 7, 2, 2, 8, 6, 9], how many DIFFERENT subsequences (chosen by index) are strictly increasing AND have the…
- What is the maximum possible SUM of a strictly increasing subsequence of [1, 101, 2, 3, 100, 4, 5]?
- The longest bitonic subsequence of an array is a subsequence that first strictly increases and then strictly decreases (either part may be…
- A pair (a, b) can follow pair (c, d) in a chain when b < c. The pairs are [(5, 24), (39, 60), (15, 28), (27, 40), (50, 90), (1, 2), (3…
- What is the minimum number of elements you must DELETE from [9, 4, 7, 2, 10, 3, 8, 11, 5] (the rest keep their order) so that the…
- What is the length of the longest common subsequence of the strings "AGGTABQZ" and "GXTXAYBZQ"?