duplicate
to find the repeated or duplicate elements in an array. duplicate({1,3,4,2,1}) --> "[1]"
duplicate({1,3,4,2,1,2,4}) --> "[1, 2, 4]"
toString()
method to return the Arrays.sort()
to sort your result. Sorting
and then traverse to check for the repeated elements.
Array Sort
. TreeSet
can radically simplify the implementation.
public static String duplicate(int[] numbers){ }
C
Java
Python