Your question is Linked List or Binary Tree Implementation. 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.
Andela Talent Cloud stores ordered workflow steps as singly linked lists. Implement reverse_between to reverse the nodes from position left through position right, inclusive, without creating replacement nodes.
The function receives head, the first ListNode in a singly linked list, and two 1-based positions, left and right. Return the new head after reversing that segment. Each node has an integer val field and a next field containing another node or None. The list must be modified in place, and node identity outside the reversed segment must remain unchanged.
For test cases, linked lists are represented as JSON arrays. The evaluation harness converts the array to linked nodes before calling the function and converts the returned list back to an array.
def reverse_between(head, left, right):