Sponsored Reserved space — layout preview until AdSense is connected
medium +28 pts

Linked list reversal

In-place pointer swap.

Implement class `Node(val, next=None)` and: `reverse_list(head: Node | None) -> Node | None` Reverse the linked list in place and return the new head.

Constraints

0 ≤ list length ≤ 10^4.

Example

head = Node(1, Node(2, Node(3)))
new_head = reverse_list(head)  # 3 → 2 → 1
28 points ~25 min

Recent Submissions

No submissions yet — hit Run Tests to try!

Hints

Iterate keeping prev, curr, next_node; reassign curr.next = prev.
Python 3
All tests passed!
Test Results
Press Ctrl+Enter or click Run Tests to execute your code.
Sponsored Reserved space — layout preview until AdSense is connected