The easiest answer is to write to understand
https://blog.csdn.net/Bob__yuan/article/details/99690889
Returns the number of methods in addition, to return the string
int i = len1, j = len2;
vector<vector<int>> dp = lcs;
while (i != 0 && j != 0) {
if (dp[i][j] == dp[i - 1][j]) i--;
else if (dp[i][j] == dp[i][j - 1]) j--;
else {
str.push_back(text1[i - 1]);
i--;
j--;
}
}
dp analysis
https://www.cnblogs.com/wkfvawl/p/9362287.html
https://blog.csdn.net/trochiluses/article/details/37966729