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

Quiz: DP on Grids and Strings: questions with answers

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

Take the timed quiz + get a certificate →
  1. Q1. In unique paths (moves only right or down), why is dp[i][j] = dp[i − 1][j] + dp[i][j − 1]?
  2. Q2. What does this print? (code)
  3. Q3. In LCS, what happens when a[i − 1] equals b[j − 1]?
  4. Q4. What does this print? (code)
  5. Q5. What is the difference between a subsequence and a substring?
  6. Q6. In edit distance, what are dp[i][0] and dp[0][j]?
  7. Q7. In the edit distance recurrence, dp[i − 1][j − 1] + 1 stands for which operation?
  8. Q8. What does this print? (code)
  9. Q9. Why is [[0] m] n a bug for a DP table in Python?
  10. Q10. You reduce the LCS table to two rows to save memory. What do you lose?