Pergunta de entrevista da empresa Expedia Group

How to find K most frequently occurring elements.

Respostas da entrevista

Sigiloso

16 de mar. de 2015

Using a hash table based mechanism

2

Sigiloso

14 de dez. de 2015

Maintain hashmap with count of each element, and keep on adding elements to min heap, till heap has less than k elements. When heap is of size k, if next element count is greater than count of root element of min heap, remove root of min heap and add this new element. When all elements has been processed, heap will contain k most frequent elements

Sigiloso

9 de mar. de 2019

creating a frequency map and then using bucket sort is a pretty cool solution too. Runs in linear time.