BENlabs interview question

A medium difficulty HackerRank problem