• + 0 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();
    }