Lintcode35 Reverse Linked List solution problem solution
[topic description]
Reverse a linked list.
Flip a linked list
[topic link]
Http://www.lintcode.com/en/problem/reverse-linked-list/
[topic Analysis]
This question requires us to flip the linked list between [m, n] intervals. For linked list flipping, it is almost always a common practice, such as p1-> p2-> p3-> p4. If we want to flip p2 and p3, we are actually mounting p3 behind p1, so we need to know the precursor node p1 of p2.
We first traverse to get the m-1 node, which is the precursor node of pm. Then traverse it in turn and deal with the mount problem.
[reference answer]
Http://www.jiuzhang.com/solutions/reverse-linked-list/