0
How do you reverse a double linked list?
How would you reverse a double linked list (turn 1,2,3 to 3,2,1) while keeping O(n) time and without creating new nodes? Could use some help on this. Thanks in advance!
1 Antwort
+ 1
Maybe you could iterate through every node and switch the links to the next and the prev node. And when you reach the last node you set the last node as root.