Pergunta de entrevista da empresa Yelp

find the smallest K elements of a given list

Resposta da entrevista

Sigiloso

22 de jun. de 2017

keep a max heap with k elements and iterate over the array add an element and then remove the max element in the heap repeat until the array has ended then the max heap represents the smallest K elements