🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← All topics

Quiz: 1D Dynamic Programming Patterns: questions with answers

10 questions, each with the answer and a short explanation.

Take the timed quiz + get a certificate →
  1. Q1. In the DP recipe, what should you decide first?
  2. Q2. What does this print? (code)
  3. Q3. In house robber, why is dp[i] = max(dp[i − 1], dp[i − 2] + money[i])?
  4. Q4. With coins {1, 3, 4} and amount 6, what does greedy (largest coin first) give, and what is optimal?
  5. Q5. What does this print? (code)
  6. Q6. In "number of ways" coin change, swapping the loops (amount outside, coins inside) counts:
  7. Q7. In the O(n²) LIS, what does dp[i] mean?
  8. Q8. What does this print? (code)
  9. Q9. Climbing stairs keeps only two variables instead of an array. Why is that allowed?
  10. Q10. What is the base value for counting ways to make amount 0 with coins?