Why Java stream takes so long? 136ms


  • 0
    I
        public int[] intersection(int[] nums1, int[] nums2) {
        Set<Integer> s1 = Arrays.stream(nums1)
                                .boxed()
                                .collect(Collectors.toSet());
        s1.retainAll(Arrays.asList(Arrays.stream(nums2).boxed().toArray()));
        return s1.stream()
                 .mapToInt(Integer::intValue)
                 .toArray();
    }

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.