We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Reverse a doubly linked list
Reverse a doubly linked list
Sort by
recency
|
696 Discussions
|
Please Login in order to post a comment
PSA: DO NOT USE KOTLIN
You cannot pass using Kotlin due to this issue, which still remains today.
My Java solution with linear time complexity and constant space complexity:
my code in go
reverse in place:
this is my solution def reverse(llist): # Write your code here current=llist prev_node=None while current: current.prev,current.next = current.next,current.prev prev_node = current current = current.prev