Problem. Given the head of a singly linked list, reverse it and return the new head.
1 → 2 → 3 → 4 → 5 → None becomes 5 → 4 → 3 → 2 → 1 → None
None becomes None
This is the canonical pointer problem: easy to state, and a reliable test of whether you can rewrite pointers without losing the rest of the list.
ML context. Reverse-mode automatic differentiation (backpropagation) records operations in the order they run and then visits them in reverse to push gradients back. When the record is a chain of nodes (a "tape"), that backward pass is exactly this lesson (Change D). Reversing linked structures also appears when you process a log or history newest-first.