uniq: Optimize time complexity for unsorted arrays