Uber interview question

Pretty simple dynamic programming question