Dynamic Programming21 sections · 916 units
Open in Course

Lessons from Edit Distance

summary

Four things to remember:

1.1. String DP compares prefixes. dp[i][j]dp[i][j] relates prefix of A to prefix of BB.

2.2. Match vs operate. When characters match, you get a free transition.

3.3. Three choices become one min. Replace, delete, insert map to three neighbors.

4.4. Base cases are edge strings. Empty-to-something costs the length. You now have three 2D patterns: resource tracking, grid navigation, and string comparison.