Infosys interview question

Programming Question was asked in the interview