6 min read
development A walkthrough of "Top K Frequent Elements": why sorting by frequency costs more than it needs to, and how bucket sort gets the answer in linear time by exploiting a bound on how large a frequency can ever be.
A walkthrough of "Top K Frequent Elements": why sorting by frequency costs more than it needs to, and how bucket sort gets the answer in linear time by exploiting a bound on how large a frequency can ever be.