Swapping Nodes in a Linked List

Medium · Linked Lists · about 15 minutes

Asked at Amazon, Meta, Microsoft, Google.

Exchange the values of two nodes: the k-th counting from the front and the k-th counting from the back (both counted from 1). Return the head.

Related guides