NVIDIA interview question

a dynamic programming coding question