Solved Leetcode 1721: Swapping Nodes in a Linked List

source: https://leetcode.com/problems/swapping-nodes-in-a-linked-list/description/ Swapping Nodes in a Linked List You are given the head of a linked list, and an integer k. Return the head of the linked list after swapping the values of the kth node from the beginning and the kth node from the end (the list is 1-indexed). Example 1: Input: head = ...