Pergunta de entrevista da empresa Alloy

One medium difficulty HackerRank question