You are viewing a single comment's thread. Return to all comments →
//Java solution using recursion function(fails for the test case 11 and 12 yet i got 85.04):
public static int stringSimilarity(String s){
int count=s.length(); for (int i = 1; i < s.length(); i++) { if(s.charAt(0)==s.charAt(i) && i<s.length()-1) {count+=1+fidd(s,i+1,1,0);} else if(s.charAt(0)==s.charAt(i) && i==s.length()-1){ count+=1; } } return count; } public static int fidd(String s ,int k ,int i ,int count){ if(s.charAt(i)==s.charAt(k) && k<s.length()-1) { count=1+fidd(s, k+1, i+1, count); } else if(s.charAt(i)==s.charAt(k) && k==s.length()-1){count=1;} else count=0; return count; }
Seems like cookies are disabled on this browser, please enable them to open this website
String Similarity
You are viewing a single comment's thread. Return to all comments →
//Java solution using recursion function(fails for the test case 11 and 12 yet i got 85.04):
public static int stringSimilarity(String s){