You are viewing a single comment's thread. Return to all comments →
Awasome, could able to do it with charm after watching this. C# code:
static int commonChild(string s1, string s2) { int[,] mat = new int[s1.Length+1, s2.Length+1]; for(int i=0; i<= s1.Length; i++){ mat[i,0] = 0; mat[0,i] = 0; }
for(int i = 0; i < s1.Length; i++){ for(int j = 0; j < s2.Length; j++){ if(s1[i] == s2[j]){ mat[i+1,j+1] = mat[i, j] + 1; } else{ mat[i+1,j+1] = mat[i+1, j] > mat[i, j+1] ? mat[i+1, j] : mat[i, j+1]; } } } return mat[s1.Length, s1.Length]; }
Seems like cookies are disabled on this browser, please enable them to open this website
Common Child
You are viewing a single comment's thread. Return to all comments →
Awasome, could able to do it with charm after watching this. C# code:
static int commonChild(string s1, string s2) { int[,] mat = new int[s1.Length+1, s2.Length+1]; for(int i=0; i<= s1.Length; i++){ mat[i,0] = 0; mat[0,i] = 0; }