LCS(Longst Common Subsequence)

    xiaoxiao2021-03-25  8

    //LCS int n,m; char s[MAX_N],t[MAX_M]; int dp[MAX_N + 1][MAX_M + 1]; void solve() { for(int i = 0;i < n;i++) for(int j = 0;j < m;j++) { if(s[i] == t[j]) dp[i + 1][j + 1] = dp[i][j] + 1; else dp[i + 1][j + 1] = max(dp[i + 1][j],dp[i][j + 1]); } } int ans = dp[n][m];
    转载请注明原文地址: https://ju.6miu.com/read-200172.html

    最新回复(0)