Infosys interview question

See above