ASUS interview question

A medium question of dynamic programming.