Question

A DP solution for LCS is producing incorrect lengths. Upon inspection, the dp table is being filled, but the values don't match expected outcomes. Which of the following is a common error in the recurrence relation for LCS?

A Not considering the case where characters text1[i-1] and text2[j-1] are equal.
B Incorrectly taking max(dp[i-1][j], dp[i][j-1]) when characters are equal.
C Initializing dp[0][j] and dp[i][0] with values other than 0.
D Using dp[i][j] = 1 + dp[i][j] when characters match.
E Iterating i and j from 0 instead of 1 for string indices.
Practice Next

Hey! Ask a query