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