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]?

  1. A. 5
  2. B. 6
  3. C. 4
  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.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic