Amazon Interview Question

Linked list problem from leetcode