- Not like normal
reversing linked list, we need to fix a
prevpointer and only move
- Use a
dummyin case left is equal to 1.
- The most important step:
tmp.next = prev.next. Don’t use tmp.next = curr.
head of a singly linked list and two integers
left <= right, reverse the nodes of the list from position
left to position
right, and return the reversed list.
Input: head = [1,2,3,4,5], left = 2, right = 4