You are viewing a single comment's thread. Return to all comments →
public static int gemstones(List<String> arr) { Map<String, Long> countmap = arr.stream().map(s -> s.split("")).map(Arrays::stream) .map(stream -> { Set<String> set = new HashSet<>(); stream.forEach(set::add); return set; }). flatMap(Set::stream). collect(Collectors.groupingBy(Function.identity(), Collectors.counting())); return (int)countmap.entrySet().stream().filter(en -> en.getValue() == arr.size()).count(); }
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 →