https://oj.leetcode.com/problems/reverse-linked-list-ii/
http://blog.csdn.net/linhuanmars/article/details/24613781
/** * definition for singly-linked list. * public class listnode { * int val; * ListNode Next; * listnode (int x) { * val = x; * next = null; * } * } */public class solution { public listnode reversebetween (Listnode head, int m, int n) { // Add dummyhead; Listnode dummyhead = new listnode (0); Dummyhead.next = head;&nbSp; // find the one to reverse ListNode pre = dummyhead; listnode node = head; for (int i = 1 ; i < m ; i ++) { pre = pre.next; node = node.next; } // reverse node (n - m) times for (int i = 0 ; i < n - m ; i ++) { ListNode next = node.next; node.next = next.next; // assuming next won ' T be null since 1 ≤ m ≤ n ≤ length of list. next.next = pre.next; pre.next = next; } head = dummyhead.next; dummyhead.next = null; return head; }}
[leetcode]92 Reverse Linked List II