IBM interview question

Testcases