Frage im Vorstellungsgespräch bei JPMorganChase

A Dynamic Programming based problem which I have to code on Codepair platform