Domanda di colloquio di IIT Academy

Dynamic programming related question with optimising it further