You are viewing a single comment's thread. Return to all comments →
public static int commonChild(string s1, string s2) { int m = s1.Length + 1, n = s2.Length + 1; int[,] LCS = new int[m, n]; for (int i = 1; i < m; i++) { for (int j = 1; j < n; j++) { if (s1[i - 1] == s2[j - 1]) LCS[i, j] = LCS[(i - 1), (j - 1)] + 1; else LCS[i, j] = Math.Max(LCS[(i - 1), j], LCS[i, (j - 1)]); } } return LCS[(m - 1), (n - 1)]; }
Common Child
You are viewing a single comment's thread. Return to all comments →