You are viewing a single comment's thread. Return to all comments →
static int commonChild(String s1, String s2) { int[][] arr = new int[s1.length() + 1][s2.length() + 1]; for (int i = 0; i < s1.length(); i++) for (int j = 0; j < s2.length(); j++) arr[i + 1][j + 1] = s1.charAt(i) == s2.charAt(j) ? arr[i][j] + 1 : Math.max(arr[i][j + 1], arr[i + 1][j]); return arr[s2.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 →