Infosys interview question

Dynamic programming question medium level leetcode