You are viewing a single comment's thread. Return to all comments →
public static int commonChild(String s1, String s2) { int max = -1 ; for(int i = 0 ; i < s1.length() ; i++){ int count = 0 ; int len = 0 ; for(int j = i ; j < s1.length() ; j++){ for(int k = len ; k < s2.length() ; k++){ if(j >= s1.length()) break ; if(s1.charAt(j) == s2.charAt(k)){ len = k + 1 ; j++ ; count++ ; } } } if(count > max) max = count ; } return max ; }
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 →
Why my this code is wrong ? Can someone give me small test cases , it will be a huge help .