You are viewing a single comment's thread. Return to all comments →
public static String twoStrings(String s1, String s2) { String maxstring = s1.length() > s2.length() ? s1 : s2; String smallstring = s1.length() <= s2.length() ? s1 : s2; Set<String> maxset = Arrays.stream(maxstring.split("")).collect(Collectors.toSet()); Set<String> smallset = Arrays.stream(smallstring.split("")).collect(Collectors.toSet()); int smallsetsize = smallset.size(); smallset.removeAll(maxset); return smallsetsize == smallset.size() ? "NO" : "YES"; }
Seems like cookies are disabled on this browser, please enable them to open this website
Two Strings
You are viewing a single comment's thread. Return to all comments →