Reverse Linked List
Given the head of a singly linked list ({ val, next } nodes), reverse it in place and return the new head. The classic three-pointer walk: keep track of prev, the current node, and save next before you overwrite the link.
// 1 -> 2 -> 3 -> null becomes 3 -> 2 -> 1 -> null
reverseLinkedList(list(1, 2, 3));