c - Algorithm to find the duplicate numbers in an array ---Fastest Way -


I need the fastest and simplest algorithm that finds duplicate numbers in an array, should also know the number of duplicates.

Example: If the array is {2,3,4,5,2,4,6,2,4,7,3,8,2}

I should know that there are four 2, two 3 and three 4.

Create a hash table where the key is the array object and the value is how often the array array related to the array has come. To do this, this is an effective way, but probably is not the fastest way.

Something like this (in pseudo code) Array for item in ifh_map = create_new_hash_map ()


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

php - jQuery AJAX Post not working -