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
|
699 Discussions
|
Please Login in order to post a comment
Reversing a doubly linked list is all about carefully swapping next and prev for each node, one wrong move and the whole chain breaks. How did you handle the pointer swap without losing track of the list?
Simple java solution TC-O(N) SC-O(1)
My Java 8 Solution
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: