Pergunta de entrevista da empresa Meta

K-max in array problem with some complications