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