HashiCorp interview question

Topk elements code is there we need to review