IBM Interview Question

Coding assessment in hacker rank