Pregunta de entrevista de Alloy

One medium difficulty HackerRank question