Deutsche Bank Interview Question

LC medium dynamic programming question