Infosys interview question

React