Classic 2D DP on prefixes.
dp[i][j] = LCS length of text1[:i] and text2[:j].
If chars equal: dp[i-1][j-1] + 1, else max(dp[i-1][j], dp[i][j-1]).
Use 1D rolling array.
Classic 2D DP on prefixes.
dp[i][j] = LCS length of text1[:i] and text2[:j].
If chars equal: dp[i-1][j-1] + 1, else max(dp[i-1][j], dp[i][j-1]).
Use 1D rolling array.