Finding the decimal dominant in an array
You are given n real numbers in an array. A number in the array is called a decimal dominant if it occurs more than n/10 times in the array. Give an O(n) time algorithm to determine if the given array has a decimal dominant.
most simple way is to use a hashmap;
ReplyDeletestoring values for each element's frequency of occurency in a separate array
and hashmapping it with the original array elements