You're following the same philosophy as the bubble sort, which is very, very, very slow. Have you tried this?: - Sort your unordered array with [quicksort](http://en.wikipedia.org/wiki/Quicksort). Quicksort is much faster than bubble sort (I know, you are not sorting, but the algorithm you follow is almost the same as bubble sort to traverse the array). - Then start removing duplicates (repeated values will be next to each other). In a `for` loop you could have two indices: `source` and `destination`. (On each loop you copy `source` to `destination` unless they are the same, and increment both by 1). Every time you find a duplicate you increment source (and don't perform the copy). UPDATE Your edited code doesn't work for the <code>case arr = new int[] {1, 2, 2, 3}</code> (the last value [3] is lost). Try moving this line: <code>whitelist[destination] = currentValue;</code> to the <code>else</code> clause and also copy it before your <code>while</code> loop. Like this: whitelist[destination] = currentValue; while(source < arr.length){ if(currentValue == arr[source]){ source++; } else { currentValue = arr[source]; destination++; source++; whitelist[destination] = currentValue; } }