1Use a (m+1) × (n+1) table with an extra row/column for the empty string base case — avoids conditional checks.
2For LCS: dp[i][j] = dp[i-1][j-1]+1 if chars match, else max(dp[i-1][j], dp[i][j-1]).
3For Edit Distance: dp[i][j] = dp[i-1][j-1] if match, else 1 + min(dp[i-1][j], dp[i][j-1], dp[i-1][j-1]).
4Space optimization: if dp[i][j] only depends on the previous row, use two 1D arrays (curr and prev).