3
ListNode *swapNodes(ListNode *head, int k) {4
// declare a dummy node6
ListNode *dummy = new ListNode(0);8
// point dummy -> next to head12
// declare a tail pointer and point to dummy14
ListNode *tail = dummy;16
// move the curr pointer (k - 1) times18
// this will maintain a gap of (k - 1) between curr and tail pointer20
ListNode *curr = head;28
// store the address in start pointer30
ListNode *start = curr;32
// maintaing a gap of (k - 1) between curr and tail, move both pointer40
// store the address of kth node from end46
swap(start->val, end->val);48
// dummy -> next will be head