Pregunta de entrevista de InRhythm

Codility challenge question. Involved coding task.