Infosys Interview Question

LC easy and medium question