Count frequencies, then retrieve the k most frequent values.
buckets[f] stores numbers that appear f times.k.Bucket indices represent frequency, so scanning from the end yields elements in descending frequency without sorting all keys.
Count frequencies, then retrieve the k most frequent values.
buckets[f] stores numbers that appear f times.k.Bucket indices represent frequency, so scanning from the end yields elements in descending frequency without sorting all keys.