You are viewing a single comment's thread. Return to all comments →
May i know what exactly is to be done here. I've brainstorming for quite a while now. My code:
int commonChild(string s1, string s2) {
int LCS[s1.size()+1][s2.size()+1];
for(int i=0;i<=s1.size();i++) { for(int j=0;j<=s2.size();j++) { if(i==0||j==0) LCS[i][j]=0;
else if(s1[i-1]==s2[j-1]) LCS[i][j] = 1+ LCS[i-1][j-1]; else LCS[i][j] = max(LCS[i-1][j],LCS[i][j-1]); }
}
return LCS[s1.size()][s2.size()];
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 →
May i know what exactly is to be done here. I've brainstorming for quite a while now. My code:
int commonChild(string s1, string s2) {
int LCS[s1.size()+1][s2.size()+1];
for(int i=0;i<=s1.size();i++) { for(int j=0;j<=s2.size();j++) { if(i==0||j==0) LCS[i][j]=0;
}
return LCS[s1.size()][s2.size()];
}