
Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
We can traverse the linked list and store the elements in an array.
Upon conversion to an array, we can swap the required elements by indexing the array.
We can rebuild the linked list using the order of the elements in the array.