← 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?
- A.The LIS of the whole array
- B.The LIS of a[i..n−1]
- C.The length of the longest increasing subsequence that ends exactly at index i
- 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 →