Citadel Securities interview question

asked to solve a problem about dynamic programming