Your question is Recursive Reverse Linked List. 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.
Searce cloud engineering workflows may process linked sequences of tasks or events that must be traversed in reverse order. Given the head of a singly linked list, reverse the list recursively and return the new head.
The input is head, either None or a reference to a ListNode with fields val and next. The function must reverse the existing links in place, without creating replacement nodes, and return the head of the reversed list. The judge serializes the returned list as an array of values for verification.
Use the recursive call to reverse the suffix before reconnecting the current node. Do not use Python list operations to perform the reversal.
def reverse_linked_list(head):