|
|
|
|
|
by drycabinet
759 days ago
|
|
Does finding the number of unique elements in a set actually require comparison of each element with everything else? Can't you use a hashtable? For every element, add it to the table (ignore if already exists), and finally, take a count of keys. |
|
That's easy, that's all of them. Sorry, could not resist.
Yes, hashing is the usual method. In a sorted list you can compare to the following element.