efficient generic duplicate finding class java

Solutions on MaxInterview for efficient generic duplicate finding class java by the best coders in the world

showing results for - "efficient generic duplicate finding class java"
Linus
20 Aug 2018
1public static <T extends Comparable<T>> void getDuplicates(T[] array) {
2        Set<T> dupes = new HashSet<T>();
3        for (T i : array) {
4            if (!dupes.add(i)) {
5                System.out.println("Duplicate element in array is : " + i);
6            }
7        }
8
9    }
similar questions