CODE/Algorithms & Data Structures

[Coderust] Swapping Nodes in a Linked List

BoriTea 2022. 5. 21. 10:42

 

Problem

 

 

 


 

Solution

 

Same method as the Remove Nth Node From End of List , except we have a third pointer that points to the Nth value from the start of the list.

 

Time Complexity

O(N)

 

 

Space Complexity

O(1)