Seems like if there exists duplicates in array, the best way is O(n)