public static void Main()
Console.WriteLine(commonChild(s1,s2));
Console.WriteLine(commonChild(s3,s4));
Console.WriteLine(commonChild(s5,s6));
string s7 = "OUDFRMYMAW";
string s8 = "AWHYFCCMQX";
Console.WriteLine(commonChild(s7,s8));
static int commonChild(string s1, string s2) {
int [,] arr = new int [s1.Length+1, s2.Length+1];
for(int i = 0; i <= s2.Length; i++)
for (int i = 0; i <= s1.Length; i++)
for (int i = 1; i <= s1.Length; i++)
for (int j = 1; j <= s2.Length; j++)
arr[i, j] = arr[i - 1, j - 1] + 1;
arr[i, j] = Max(arr[i-1, j], arr[i, j-1]);
return arr[s1.Length, s2.Length];
private static int Max(int int1, int int2)
return int1 > int2 ? int1 : int2;