4 ms·
The O(n) solutions sound way more interesting! 1. Iterate through all key,value pairs once, keeping track of the 10 most common 2. Run quickselect 10 times 3.
by jastr 13y ago
The O(n) solutions sound way more interesting!
1. Iterate through all key,value pairs once, keeping track of the 10 most common
2. Run quickselect 10 times
3. Coolest (and an interview question in it's own right) - modify quickselect to return the top 10!