The problem. Given the head of a doubly linked list, reverse it in place and return the new head. Every node's next and prev must be correct afterwards.
1 <-> 2 <-> 3 <-> 4 -> 4 <-> 3 <-> 2 <-> 1
5 <-> 9 -> 9 <-> 5
7 -> 7Members only · free account
The rest of this lesson, with 6 more sections, 1 drawing, a dry-run simulator and code in JavaScript, Python, Java and C++, opens with a free account.
Not ready yet? The Arrays course is free to read, no account needed.
In the rest of this lesson