考虑两个字符串,我们用dp[i][j]表示字串第到i个和字符串到第j个的总数,由于字串必须连续 因此dp[i][j]能够有dp[i][j-1]和dp[i-1][j-1]递推而来,而不能由dp[i-1][j]递推而来.而后者的条件 是字串的第i个和字符串相等. A subsequence of a given sequence is just the given sequence with some elements (possibly none) left out. Formally, give…