Given the head of a singly linked list, reverse the list in place and return the new head. Each node contains an integer val and a pointer next. If the list is empty or has one node, return it unchanged.
Example 1:
Input: head = [1, 2, 3, 4, 5]
Output: [5, 4, 3, 2, 1]
Explanation: Reversing the pointers makes the last node the new head.
Example 2:
Input: head = [1, 2]
Output: [2, 1]
Explanation: The second node points to the first after reversal.
0 <= number of nodes <= 5000-5000 <= Node.val <= 5000