Problem
Reverse a singly linked list and return the new head.
Example 1
Input: head = [1,2,3,4,5]
Output: [5,4,3,2,1]
Constraints
- The number of nodes is in the range [0, 5000]
Notes
- Focus on the underlying recursion pattern.
- Write the cleanest correct solution before optimizing further.
- Hidden tests cover larger edge cases than the visible examples.