As reported: Cisco, networking/C-focused role, round 2 DSA part (2026): reverse a doubly linked list.
Each node of a doubly linked list has val, prev and next. Given the head, reverse the list in place and return the new head. After reversing, walking next from the new head and walking prev from the new tail must both be correct.
Example 1
head = 1 <-> 2 <-> 3 <-> 4 <-> 5 -> 5 <-> 4 <-> 3 <-> 2 <-> 1
Example 2
head = 1 <-> 2 -> 2 <-> 1
Constraints: 0 ≤ length ≤ 3·10^4.
Code runner format: one line, the list's values as a JSON array. The harness builds the list, calls reverseDLL(head), then prints the values walking next from the returned head, and the values walking prev back from the last node.