Your question is Reverse Linked List and Test. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Google Chrome may represent a sequence of navigation records as a singly linked list. Implement reverse_linked_list to reverse the list in place and return the new head. Also design tests that verify pointer order, boundary cases, and that the original nodes are reused rather than copied.
The input is head, either None or a reference to a ListNode object. Each ListNode has an integer value field and a next field containing another ListNode or None. Return the head of the reversed list. Do not allocate replacement list nodes, and do not modify node values.
For the JSON test cases below, each input array represents node values in traversal order. The test harness converts the array to linked nodes before calling the function and serializes the returned list back to an array.
def reverse_linked_list(head):