Infosys interview question

Coding