Dynamic Programming21 sections · 916 units
Open in Course

Lessons from Edit Distance

summary

Three patterns to remember:

1.1. More operations means more transitions. LCS has 2 choices, Edit Distance has 3.

2.2. Base cases change with the problem. LCS starts with 0s, Edit Distance starts with indices.

3.3. The same 2D (two-dimensional) structure works for many string problems. dp[i][j]dp[i][j] with two strings is universal. You've now learned the two pillars of string DP. Apply these patterns when you encounter similar problems.