Meta interview question

K-max in array problem with some complications