🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: 1D Dynamic Programming Patterns: all 10 questions

Quiz: 1D Dynamic Programming Patterns · Question 7 of 10

In the O(n²) LIS, what does dp[i] mean?

In the O(n²) LIS, what does dp[i] mean?

  1. A.The LIS of the whole array
  2. B.The LIS of a[i..n−1]
  3. C.The length of the longest increasing subsequence that ends exactly at index i
  4. D.The number of increasing subsequences
Answer & explanation

Correct answer: The length of the longest increasing subsequence that ends exactly at index i

Because it must end at i, the final answer is max(dp), not dp[n − 1].

Can you get the rest right without peeking?

Take the timed Quiz: 1D Dynamic Programming Patterns quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →