Infosys interview question

Algorithms