Uber interview question

Coding question related to DP and graphs