Infosys interview question

Average Question from leetcode to solve