Sort the array first (you can do it in worst case O(n log n) using QuickSort ). Then read the array from the beginning till the end ONCE ( O(n) ), and if you come across a duplicate remove it.
So the total complexity is O(n log n), which is much better than O(n^2) which would result when using...