I want to detect duplicate values in a Java array. For example:
int[] array = { 3, 3, 3, 1, 5, 8, 11, 4, 5 };
How could I get the specific
Sort the array, then either scan it or Arrays.binarySearch + scan in either direction. Due to much fewer allocations and no wrapping, this can be faster, especially on larger arrays.
Arrays.binarySearch