Amazon interview question

Linked list problem and Dynamic Programming