Reverse size nodes of the list starting at position left (the head is position 1) and return the head. The rest of the list stays in place.
For 1 -> 2 -> 3 -> 4 -> 5, left = 2 and size = 3 give 1 -> 4 -> 3 -> 2 -> 5.
The tests show a list as a Python list of its values: [1, 2, 3] stands for 1 -> 2 -> 3.
Example 1
Input:
reverse_between(head, 2, 3) # head = 1 -> 2 -> 3 -> 4 -> 5
Output:
[1, 4, 3, 2, 5]
Example 2
Input:
reverse_between(head, 1, 1) # head = 5
Output:
[5]
1 <= number of nodes <= 1000001 <= left and 1 <= sizeleft + size - 1 <= number of nodesNo results yet
Run your code to check it against the examples, or submit to run every test.