Swap Nth Node with Head
Given the head of a singly linked list and 'n', swap the head with the nth node. Return the head of the new linked list.
We'll cover the following
Statement
Given the head of a singly linked list and , swap the head with the node. Return the head of the new linked list.
Example
Let’s take a look at an example where n
is equal to .
Level up your interview prep. Join Educative to access 80+ hands-on prep courses.