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 .
After swapping the Nth node with head, ...
Access this course and 1400+ top-rated courses and projects.