Two Sigma interview question

Two dynamic programming questions.