I have generated an array of 5 random integers from 1-5. Here is what the array looks like now: myArray[5] = {3, 3, 1, 4, 5}
I have now sorted the array of
Make a hash and initialize with zero.
int hash[10000]={0};
for(int i=0;i
the hash at index arr[i] will hold value which is the count of occurrence of that number. As hash[arr[i]]++
will increment the count at index equal to the value of arr[i]. This way we can check which value occurred how many times by checking hash[arr[i]] where arr[i] is value to be checked.