Quant Memo
Coding/●●●●●

Reverse a singly linked list

Given the head of a singly linked list, reverse it in place and return the new head.

1 -> 2 -> 3 -> 4 -> None
becomes
4 -> 3 -> 2 -> 1 -> None

Reverse the list iteratively in O(n)O(n) time and O(1)O(1) extra space. Copying values into a Python list and rebuilding is not accepted, the point is pointer surgery.

Your answer

This one is open-ended. Work it through, then check your reasoning against the full solution.

More Coding questions