You are viewing a single comment's thread. Return to all comments →
One more solution
public static int gemstones(List<String> arr) { Set<Set<String>> countset = arr.stream().map(s -> s.split("")).map(Arrays::stream) .map(stream -> { Set<String> set = new HashSet<>(); stream.forEach(set::add); return set; }).collect(Collectors.toSet()); Iterator<Set<String>> iterator = countset.iterator(); Set<String> firstSet = iterator.next(); while(iterator.hasNext()) { Set<String> set = iterator.next(); firstSet.retainAll(set); } return firstSet.size(); }
Seems like cookies are disabled on this browser, please enable them to open this website
Gemstones
You are viewing a single comment's thread. Return to all comments →
One more solution