GATE Computer ScienceHardGATE CS (PYQ pattern)

What is the largest sum of an increasing subsequence (strictly increasing, not necessarily contiguous) of [3, 100, 4, 5, 2, 200, 6, 7, 8, 1, 150, 9]?

  1. A. 253
  2. B. 200
  3. C. 303
  4. D. 183

Correct answer: C. 303

With m[i] = a[i] + max m[j] over j < i, a[j] < a[i], the best is 3 + 100 + 200 = 303. The longest increasing subsequence (3, 4, 5, 6, 7, 8, 150, length 7) has a much smaller sum of 183.

More Algorithms questions

Exams that ask this topic