Infosys interview question

How to avoid loop inside loop