Morgan Stanley Interview Question

The coding questions were based on Dynamic programming. One question it was easy but you can use C,C++ and python(2.7). As java wasn't available I couldnt solve it.