Swapping Nodes in a Linked List
Try to solve the Swapping Nodes in a Linked List problem.
We'll cover the following
Statement
Given the linked list and an integer, k
, return the head of the linked list after swapping the values of the node from the beginning and the node from the end of the linked list.
Note: We’ll number the nodes of the linked list starting from to .
Constraints:
- The linked list will have
n
number of nodes. -
k
n
-
Node.value
Examples
Create a free account to view this lesson.
Continue your learning journey with a 14-day free trial.
By signing up, you agree to Educative's Terms of Service and Privacy Policy