Pergunta de entrevista da empresa Yandex

write a function that inputs and array and a number K. and returns K largests element. what is the complexity

Resposta da entrevista

Sigiloso

6 de abr. de 2020

insert 3 first values of array in tmp_array. find its minimum value and its index. scan the rest of the array. if a new value is bigger than the saved mean. replace it in the minimun value position. again , find the minimum value of tmp_array continue this until the end of the input array. complexity is (o(n-k)x(k))

1