| 1 | Initialize dp[0][j] | (0,0 to 0,7) | N/A | dp[0][j] = j | [0,1,2,3,4,5,6,7]
[ , , , , , , , ]
[ , , , , , , , ]
[ , , , , , , , ]
[ , , , , , , , ]
[ , , , , , , , ]
[ , , , , , , , ] |
| 2 | Initialize dp[i][0] | (1,0 to 6,0) | N/A | dp[i][0] = i | [0,1,2,3,4,5,6,7]
[1, , , , , , , ]
[2, , , , , , , ]
[3, , , , , , , ]
[4, , , , , , , ]
[5, , , , , , , ]
[6, , , , , , , ] |
| 3 | Compare 'k' and 's' | (1,1) | 'k' vs 's' | 1 + min(1,1,0) = 1 | [0,1,2,3,4,5,6,7]
[1,1, , , , , , ]
[2, , , , , , , ]
[3, , , , , , , ]
[4, , , , , , , ]
[5, , , , , , , ]
[6, , , , , , , ] |
| 4 | Compare 'k' and 'i' | (1,2) | 'k' vs 'i' | 1 + min(1,1,1) = 2 | [0,1,2,3,4,5,6,7]
[1,1,2, , , , , ]
[2, , , , , , , ]
[3, , , , , , , ]
[4, , , , , , , ]
[5, , , , , , , ]
[6, , , , , , , ] |
| 5 | Compare 'i' and 'i' | (2,2) | 'i' vs 'i' | dp[1][1] = 1 | [0,1,2,3,4,5,6,7]
[1,1,2, , , , , ]
[2,2,1, , , , , ]
[3, , , , , , , ]
[4, , , , , , , ]
[5, , , , , , , ]
[6, , , , , , , ] |
| 6 | Fill rest of dp table step-by-step | (i,j) | Compare s1[i-1] and s2[j-1] | Calculate dp[i][j] | Table fills with minimum edits for each prefix pair |
| 7 | Final answer | (6,7) | 'n' vs 'g' | 3 | [0,1,2,3,4,5,6,7]
[1,1,2,3,4,5,6,7]
[2,2,1,2,3,4,5,6]
[3,3,2,1,2,3,4,5]
[4,4,3,2,1,2,3,4]
[5,5,4,3,2,2,3,4]
[6,6,5,4,3,3,3,3] |