Lucid Software interview question

Hacker rank programming exercise (1 question).