Pregunta de entrevista de ASUS

A medium question of dynamic programming.