public ListNode reverseBetween(ListNode head, int m, int n) {
ListNode dummy = new ListNode(0); //虚拟头结点往往是有必要的,好处非常明显
dummy.next = head;
ListNode pre = dummy;
for(int i = 1; i < m; i++){
pre = pre.next;
}
head = pre.next;
for(int i = m; i < n; i++){
ListNode nex = head.next;
head.next = nex.next;
nex.next = pre.next;
pre.next = nex;
}
return dummy.next;
}