IBM interview question

Coding assessment in hacker rank