Amazon interview question

linked list problem leetcode medium