Friday, March 11, 2022

Two arrays common numbers with minimum complexity

public void findCommon(in[] a, int[] b){

    Set<Integer> s = new HashSet(Arrays.stream(a).boxed().collect(Collectors.toList()));

    s.retainAll(Arrays.stream(b).boxed().collect(Collectors.toList()))

   System.out.println("Find common number:"+s)

}


No comments:

Post a Comment