One solution is to create an array of size = (max element in array) and then mark that element as 1 in array if it found otherwise 0. And after that count no of 1 of unique no of elements in array.
But Here’s a problem when I need to mark large integers like 10^9. I can’t create such large array. So,Instead I created a Hash Table and stored my data in it.
Storing value in hashmap and then finding the size of hash map take much time as STL or these hash maps are slow.
Can you guys suggest any other efficient solution of it. I hope you guys always have something new.