VNG Corporation Interview Question

Solving a queue problem with heap