Google interview question

Dynamic programming problem for first interviewer. Linked list question with the second interviewer.