swap first and last kth elements on a linked list