04.10 · Lesson
Two Strings: LCS and Edit Distance
When a question gives you two strings, the state is a position in each:
f(i, j) = the answer for a[i..] and b[j..]
- Characters match: use them and move both pointers.
- They don’t match: try each allowed move and keep the best.
- Base case: one string is used up.
solulu Pro
Continue this lesson with Pro
Inside: 4 sections · 2 videos · quiz.
- Try it before reading on
- Longest common subsequence (LCS)
- Edit distance
- Related questions
Lifetime ₹1,999 ₹999 · Launch offer
Item 36 of 44 · updated 2026-10-13