public static Boolean cmprStr( String s1, String s2 )
{
// STUFF
}
I want to iterate through s1 to make sure that every character in s1 is incl
All the other answers are O(n^2). Here's a way that is linear in time (i.e. O(n)) using Google Guava:
public static boolean cmprStr(String s1, String s2) {
Set desiredCharacters = Sets.newHashSet(Lists.charactersOf(s2));
return Sets.difference(Sets.newHashSet(Lists.charactersOf(s1)), desiredCharacters).isEmpty();
}