solve(values, left, right) builds a singly linked list from values, reverses the
nodes from position left to position right (1-based, inclusive, left <= right)
and returns the values. Everything outside that window keeps its place. Do it in one
pass.
Walk to the node just before position left (use a dummy head so left = 1 is not a
special case). Then repeat right - left times: take the node after the window's current
first node and move it to the front of the window.
Examples
solve([1,2,3,4,5], 2, 4) → [1,4,3,2,5]
solve([3,5], 1, 2) → [5,3]
solve([1,2,3], 2, 2) → [1,2,3] // a window of one nodeSample tests