Amazon interview question

Leetcode question was tricky related to linked list