i tend to make a method which compares between 2 strings, str1 and str2 and should return true in the terms:
-every character in str1 must show up in str 2 at least once or more and in the same order
-str2 must be the same length or longer than str1
-str2 should not contain any character that isn't in str1
otherwise it should reture false.
for example if str1=abbcd and str2=abbcccd it should return true
if str1=abbcd and str2=abcd it should return false
and im trying to make it in a recursive way and without loops
and i ended up doing this...
public static boolean compare (String s, String t)
{
boolean result;
if (stringSum(t, 0)>=stringSum(s, 0)){
return true;
}
return false;
}
private static int stringSum(String s, int i)
{
if (i==s.length())
return 0;
return ((int)s.charAt(i)+ stringSum (s, i+1));
}
im stuck without finding away to do it....may i have someone's guidance ?