Reverse Linked List II

ID: 36; medium; 翻转链表(二)

Solution 1 (Java)

Notes

We have three major steps here:

  1. We first proceed to the (m-1)-th node, which is the node before the m-th node. Then we keep track of both of them.

  2. We reverse from m to n using the same technique used in the classical reverse linked list.

  3. Lastly, do not forget to connect the middle part, i.e., the reversed linked list, with mPrev and cur pointer.

Last updated

Was this helpful?