IBM interview question

Hacker rank technical coding test.