remove all duplicate elements in array, complexity O(n) OK