Valeo interview question

a dp problem