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.

Comments

  1. most simple way is to use a hashmap;
    storing values for each element's frequency of occurency in a separate array
    and hashmapping it with the original array elements

    ReplyDelete

Post a Comment

Popular posts from this blog