Infogain Interview Question

Coding question in technical interview