Infosys interview question

LC easy and medium question