Computing the statistical mode
问题 I'm currently trying to verify whether or not, given an unsorted array A of length N and an integer k, whether there exists some element that occurs n/k times or more. My thinking for this problem was to compute the mode and then compare this to n/k. However, I don't know how to compute this mode quickly. My final result needs to be n log(k), but I have no idea really on how to do this. The quickest I could find was n k... 回答1: Use a hash table to count the frequency of each value: uint[int]