Pergunta de entrevista da empresa Amazon

You want to keep the largest 1000 integer numbers from incoming pockets containing integers. Please write a program on how to do it.

Respostas da entrevista

Sigiloso

4 de fev. de 2016

What does pockets mean ? Is it an input stream ?

Sigiloso

4 de fev. de 2016

What does pockets mean ? Is it an input stream ?

Sigiloso

13 de mai. de 2019

The solution is to use a min heap of size 1000. The smallest element is the root element so you can just compare each new number to the root and replace it if the new number is bigger.