Canva Interview Question

Dynamic programming problem with optimization